Chore/task contract local state guard#25
Merged
Conversation
zywkloo
commented
Jun 11, 2026
zywkloo
left a comment
Owner
Author
There was a problem hiding this comment.
This PR has two critical logic issues/anti-patterns that need to be addressed:
1. Global side-effect of modifying info/exclude
In scripts/wtcraft cmd_new, there is a block that modifies info/exclude:
local exclude_file
exclude_file="$(git -C "$wt_path" rev-parse --git-path info/exclude)"Issue: Git Worktrees share the same core .git directory structure. The path returned for info/exclude is actually the main repository's global .git/info/exclude.
- When appending
/.worktree-task.md, it not only ignores the file in the newly created worktree, but also globally ignores it in the main repository root and all other worktrees. info/excludeis local and unversioned. If other developersgit clonethe project, Git will still track these files until they runwtcraft newfor the first time, causing inconsistent environments across the team.
Recommendation: Remove this "magic" code that mutates Git's local config. If the goal is to ignore.worktree-task.md, explicitly add it to the project's version-controlled.gitignore(or havewtcraft initappend it to the user's.gitignore).
2. Broken workflow between /planwt and wtcraft new (Data Loss)
The README updates the workflow to expect /planwt to do both steps:
/planwt add oauth login flow # 1. plan task + create worktree
Issue: Under the current code, this triggers a severe bug:
- According to
templates/.claude/commands/planwt.md, the Agent will first write the planned.worktree-task.mdinto the repo root. - Then it executes
wtcraft new <branch>. - However,
cmd_newcurrently unconditionally overwrites the file with a blank template:local task_file="${wt_path}/.worktree-task.md" cp "${TEMPLATE_DIR}/worktrees/.worktree-task.md" "$task_file"
Consequence: The rich plan Claude generated is left abandoned in the repo root, while the newly created worktree gets a blank template!
🛠️ Suggested Fixes
- Remove the
info/excludemutation logic entirely. - Update the task generation logic in
scripts/wtcraftto "absorb" the existing plan if it was generated in the repo root:
local task_file="${wt_path}/.worktree-task.md"
if [ -f "${repo_root}/.worktree-task.md" ]; then
mv "${repo_root}/.worktree-task.md" "$task_file"
else
cp "${TEMPLATE_DIR}/worktrees/.worktree-task.md" "$task_file"
fi…ole-models - Remove info/exclude magic from cmd_new (global side-effect anti-pattern) - Make cmd_new state-aware: mv existing plan from repo root, else fallback to template - Have cmd_init append /.worktree-task.md to user's .gitignore (version-controlled) - Restore role-models.yml in cmd_init, help text, and templates - Restore repo structure and model knowledge policy sections in AGENTS.md/CLAUDE.md - Rewrite docs/local-state-anti-patterns.md as ADR - Fix smoke tests to commit init scaffolding before creating worktrees
- Directs agent to read template for frontmatter schema - Explicitly asks agent to populate branch, created, base - Explains that wtcraft new absorbs the root plan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.