From 745e52723ce6c23e3ee2148ea8eea8dcce829ae1 Mon Sep 17 00:00:00 2001 From: Oskar Kapala Date: Wed, 3 Jun 2026 17:41:35 +0200 Subject: [PATCH] feat(skills): worktree-aware skill for Claude Code Encodes branch hygiene for CC running in task worktrees: commit only to assigned branch, no push origin master, no touching main checkout, no git add -A, no worktree management, mandatory final report. --- .claude/skills/worktree-aware/SKILL.md | 81 ++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .claude/skills/worktree-aware/SKILL.md diff --git a/.claude/skills/worktree-aware/SKILL.md b/.claude/skills/worktree-aware/SKILL.md new file mode 100644 index 0000000..78538b4 --- /dev/null +++ b/.claude/skills/worktree-aware/SKILL.md @@ -0,0 +1,81 @@ +--- +name: worktree-aware +description: > + Use when working in a git worktree checkout for a parallel agent task. + The presence of an .agent-task file in the current working directory indicates + a task worktree (NOT the main checkout). Encodes branch hygiene: commit only + to the assigned task branch, NEVER push origin master, NEVER touch the main + checkout at ~/homelab-codex-ws, NEVER manage worktrees yourself. On task + completion, report the branch name verbatim and stop — the human merges via + scripts/dev/agent.sh. +--- + +## When this applies + +- `.agent-task` present in your `cwd` → you are in a task worktree. Apply all rules below. +- `.agent-task` absent → you are in the main checkout. Do NOT treat yourself as a task agent. + In the main checkout these rules do not apply. + +## Reading the marker + +`.agent-task` is a YAML file. Your assigned branch is the value of the `branch:` key, e.g.: + +```yaml +task: my-feature +branch: task/my-feature +parent_commit: abc1234 +created_utc: 2026-06-03T10:00:00Z +worktree_path: /home/oskar/homelab-codex-ws-my-feature +``` + +Always read this file first before taking any action. + +## Rules + +1. **Commit only to your branch.** + Before any `git commit`, run `git status` and confirm it says `On branch task/`. + If it does not, stop immediately and report the discrepancy. + +2. **Push only to your branch.** + The only permitted push is `git push origin task/`. + NEVER `git push origin master` or any other branch. + +3. **Do not touch the main checkout.** + `~/homelab-codex-ws/` is the main checkout — deploy-only, owned by the human. + Do not read from, write to, or execute commands inside it. + +4. **Stay scoped.** + Only change files directly related to your assigned task. + If you notice other problems, report them in your final summary as separate follow-up proposals. + Do not fix them in this worktree. + +5. **Never `git add -A`.** + Always stage specific files by name: `git add path/to/file`. + +6. **Do not manage worktrees.** + Never run `git worktree add/remove` or invoke `scripts/dev/agent.sh`. + Worktree lifecycle is the human's responsibility. + +7. **Final report before stopping.** + When the task is done, provide a structured report containing: + - Files changed (path and one-line summary of change) + - Tests run and results + - All commit hashes on the task branch + - **Branch name verbatim** (copy-paste ready) + - Follow-up items as bulleted proposals for separate tasks + +## Definition of Done + +- All commits are on `task/` (verify with `git log --oneline master..task/`) +- Test suite passes +- Branch pushed: `git push origin task/` +- Full report delivered in conversation + +## What you do NOT do + +- Merge branches +- Create or push tags +- Run deploys or healthchecks against production nodes +- Delete branches or worktrees +- Modify files in other worktrees +- Push to `origin master` under any circumstances