Skip to content

Chore/task contract local state guard#25

Merged
zywkloo merged 7 commits into
mainfrom
chore/task-contract-local-state-guard
Jun 11, 2026
Merged

Chore/task contract local state guard#25
zywkloo merged 7 commits into
mainfrom
chore/task-contract-local-state-guard

Conversation

@zywkloo

@zywkloo zywkloo commented Jun 11, 2026

Copy link
Copy Markdown
Owner

No description provided.

@zywkloo zywkloo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/exclude is local and unversioned. If other developers git clone the project, Git will still track these files until they run wtcraft new for 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 have wtcraft init append 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.md into the repo root.
  • Then it executes wtcraft new <branch>.
  • However, cmd_new currently 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

  1. Remove the info/exclude mutation logic entirely.
  2. Update the task generation logic in scripts/wtcraft to "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

zywkloo added 4 commits June 10, 2026 22:28
…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
@zywkloo zywkloo merged commit d6c218b into main Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant