diff --git a/codex/skills/executing-plans/SKILL.md b/codex/skills/executing-plans/SKILL.md index e67f94c..a591862 100644 --- a/codex/skills/executing-plans/SKILL.md +++ b/codex/skills/executing-plans/SKILL.md @@ -65,6 +65,6 @@ After all tasks complete and verified: ## Integration **Required workflow skills:** -- **superpowers:using-git-worktrees** - REQUIRED: Set up isolated workspace before starting +- **superpowers:using-git-worktrees** - Ensures isolated workspace (creates one or verifies existing) - **superpowers:writing-plans** - Creates the plan this skill executes - **superpowers:finishing-a-development-branch** - Complete development after all tasks diff --git a/codex/skills/finishing-a-development-branch/SKILL.md b/codex/skills/finishing-a-development-branch/SKILL.md index c308b43..43da0ae 100644 --- a/codex/skills/finishing-a-development-branch/SKILL.md +++ b/codex/skills/finishing-a-development-branch/SKILL.md @@ -9,7 +9,7 @@ description: Use when implementation is complete, all tests pass, and you need t Guide completion of development work by presenting clear options and handling chosen workflow. -**Core principle:** Verify tests → Present options → Execute choice → Clean up. +**Core principle:** Verify tests → Detect environment → Present options → Execute choice → Clean up. **Announce at start:** "I'm using the finishing-a-development-branch skill to complete this work." @@ -37,7 +37,24 @@ Stop. Don't proceed to Step 2. **If tests pass:** Continue to Step 2. -### Step 2: Determine Base Branch +### Step 2: Detect Environment + +**Determine workspace state before presenting options:** + +```bash +GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P) +GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P) +``` + +This determines which menu to show and how cleanup works: + +| State | Menu | Cleanup | +|-------|------|---------| +| `GIT_DIR == GIT_COMMON` (normal repo) | Standard 4 options | No worktree to clean up | +| `GIT_DIR != GIT_COMMON`, named branch | Standard 4 options | Provenance-based (see Step 6) | +| `GIT_DIR != GIT_COMMON`, detached HEAD | Reduced 3 options (no merge) | No cleanup (externally managed) | + +### Step 3: Determine Base Branch ```bash # Try common base branches @@ -46,9 +63,9 @@ git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null Or ask: "This branch split from main - is that correct?" -### Step 3: Present Options +### Step 4: Present Options -Present exactly these 4 options: +**Normal repo and named-branch worktree — present exactly these 4 options:** ``` Implementation complete. What would you like to do? @@ -61,30 +78,45 @@ Implementation complete. What would you like to do? Which option? ``` +**Detached HEAD — present exactly these 3 options:** + +``` +Implementation complete. You're on a detached HEAD (externally managed workspace). + +1. Push as new branch and create a Pull Request +2. Keep as-is (I'll handle it later) +3. Discard this work + +Which option? +``` + **Don't add explanation** - keep options concise. -### Step 4: Execute Choice +### Step 5: Execute Choice #### Option 1: Merge Locally ```bash -# Switch to base branch +# Get main repo root for CWD safety +MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel) +cd "$MAIN_ROOT" + +# Merge first — verify success before removing anything git checkout - -# Pull latest git pull - -# Merge feature branch git merge # Verify tests on merged result -# If tests pass -git branch -d +# Only after merge succeeds: cleanup worktree (Step 6), then delete branch ``` -Then: Cleanup worktree (Step 5) +Then: Cleanup worktree (Step 6), then delete branch: + +```bash +git branch -d +``` #### Option 2: Push and Create PR @@ -103,7 +135,7 @@ EOF )" ``` -Then: Cleanup worktree (Step 5) +**Do NOT clean up worktree** — user needs it alive to iterate on PR feedback. #### Option 3: Keep As-Is @@ -127,36 +159,46 @@ Wait for exact confirmation. If confirmed: ```bash -git checkout +MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel) +cd "$MAIN_ROOT" +``` + +Then: Cleanup worktree (Step 6), then force-delete branch: +```bash git branch -D ``` -Then: Cleanup worktree (Step 5) +### Step 6: Cleanup Workspace -### Step 5: Cleanup Worktree +**Only runs for Options 1 and 4.** Options 2 and 3 always preserve the worktree. -**For Options 1, 2, 4:** - -Check if in worktree: ```bash -git worktree list | grep $(git branch --show-current) +GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P) +GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P) +WORKTREE_PATH=$(git rev-parse --show-toplevel) ``` -If yes: +**If `GIT_DIR == GIT_COMMON`:** Normal repo, no worktree to clean up. Done. + +**If worktree path is under `.worktrees/`, `worktrees/`, or `~/.config/superpowers/worktrees/`:** Superpowers created this worktree — we own cleanup. + ```bash -git worktree remove +MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel) +cd "$MAIN_ROOT" +git worktree remove "$WORKTREE_PATH" +git worktree prune # Self-healing: clean up any stale registrations ``` -**For Option 3:** Keep worktree. +**Otherwise:** The host environment (harness) owns this workspace. Do NOT remove it. If your platform provides a workspace-exit tool, use it. Otherwise, leave the workspace in place. ## Quick Reference | Option | Merge | Push | Keep Worktree | Cleanup Branch | |--------|-------|------|---------------|----------------| -| 1. Merge locally | ✓ | - | - | ✓ | -| 2. Create PR | - | ✓ | ✓ | - | -| 3. Keep as-is | - | - | ✓ | - | -| 4. Discard | - | - | - | ✓ (force) | +| 1. Merge locally | yes | - | - | yes | +| 2. Create PR | - | yes | yes | - | +| 3. Keep as-is | - | - | yes | - | +| 4. Discard | - | - | - | yes (force) | ## Common Mistakes @@ -165,13 +207,25 @@ git worktree remove - **Fix:** Always verify tests before offering options **Open-ended questions** -- **Problem:** "What should I do next?" → ambiguous -- **Fix:** Present exactly 4 structured options +- **Problem:** "What should I do next?" is ambiguous +- **Fix:** Present exactly 4 structured options (or 3 for detached HEAD) -**Automatic worktree cleanup** -- **Problem:** Remove worktree when might need it (Option 2, 3) +**Cleaning up worktree for Option 2** +- **Problem:** Remove worktree user needs for PR iteration - **Fix:** Only cleanup for Options 1 and 4 +**Deleting branch before removing worktree** +- **Problem:** `git branch -d` fails because worktree still references the branch +- **Fix:** Merge first, remove worktree, then delete branch + +**Running git worktree remove from inside the worktree** +- **Problem:** Command fails silently when CWD is inside the worktree being removed +- **Fix:** Always `cd` to main repo root before `git worktree remove` + +**Cleaning up harness-owned worktrees** +- **Problem:** Removing a worktree the harness created causes phantom state +- **Fix:** Only clean up worktrees under `.worktrees/`, `worktrees/`, or `~/.config/superpowers/worktrees/` + **No confirmation for discard** - **Problem:** Accidentally delete work - **Fix:** Require typed "discard" confirmation @@ -183,18 +237,15 @@ git worktree remove - Merge without verifying tests on result - Delete work without confirmation - Force-push without explicit request +- Remove a worktree before confirming merge success +- Clean up worktrees you didn't create (provenance check) +- Run `git worktree remove` from inside the worktree **Always:** - Verify tests before offering options -- Present exactly 4 options +- Detect environment before presenting menu +- Present exactly 4 options (or 3 for detached HEAD) - Get typed confirmation for Option 4 - Clean up worktree for Options 1 & 4 only - -## Integration - -**Called by:** -- **subagent-driven-development** (Step 7) - After all tasks complete -- **executing-plans** (Step 5) - After all batches complete - -**Pairs with:** -- **using-git-worktrees** - Cleans up worktree created by that skill +- `cd` to main repo root before worktree removal +- Run `git worktree prune` after removal diff --git a/codex/skills/requesting-code-review/SKILL.md b/codex/skills/requesting-code-review/SKILL.md index fe7c8d9..34b8340 100644 --- a/codex/skills/requesting-code-review/SKILL.md +++ b/codex/skills/requesting-code-review/SKILL.md @@ -5,7 +5,7 @@ description: Use when completing tasks, implementing major features, or before m # Requesting Code Review -Dispatch superpowers:code-reviewer subagent to catch issues before they cascade. The reviewer gets precisely crafted context for evaluation — never your session's history. This keeps the reviewer focused on the work product, not your thought process, and preserves your own context for continued work. +Dispatch a code reviewer subagent to catch issues before they cascade. The reviewer gets precisely crafted context for evaluation — never your session's history. This keeps the reviewer focused on the work product, not your thought process, and preserves your own context for continued work. **Core principle:** Review early, review often. @@ -29,16 +29,15 @@ BASE_SHA=$(git rev-parse HEAD~1) # or origin/main HEAD_SHA=$(git rev-parse HEAD) ``` -**2. Dispatch code-reviewer subagent:** +**2. Dispatch code reviewer subagent:** -Use Task tool with superpowers:code-reviewer type, fill template at `code-reviewer.md` +Use Task tool with `general-purpose` type, fill template at `code-reviewer.md` **Placeholders:** -- `{WHAT_WAS_IMPLEMENTED}` - What you just built +- `{DESCRIPTION}` - Brief summary of what you built - `{PLAN_OR_REQUIREMENTS}` - What it should do - `{BASE_SHA}` - Starting commit - `{HEAD_SHA}` - Ending commit -- `{DESCRIPTION}` - Brief summary **3. Act on feedback:** - Fix Critical issues immediately @@ -56,12 +55,11 @@ You: Let me request code review before proceeding. BASE_SHA=$(git log --oneline | grep "Task 1" | head -1 | awk '{print $1}') HEAD_SHA=$(git rev-parse HEAD) -[Dispatch superpowers:code-reviewer subagent] - WHAT_WAS_IMPLEMENTED: Verification and repair functions for conversation index +[Dispatch code reviewer subagent] + DESCRIPTION: Added verifyIndex() and repairIndex() with 4 issue types PLAN_OR_REQUIREMENTS: Task 2 from docs/superpowers/plans/deployment-plan.md BASE_SHA: a7981ec HEAD_SHA: 3df7661 - DESCRIPTION: Added verifyIndex() and repairIndex() with 4 issue types [Subagent returns]: Strengths: Clean architecture, real tests @@ -82,7 +80,7 @@ You: [Fix progress indicators] - Fix before moving to next task **Executing Plans:** -- Review after each batch (3 tasks) +- Review after each task or at natural checkpoints - Get feedback, apply, continue **Ad-Hoc Development:** diff --git a/codex/skills/requesting-code-review/code-reviewer.md b/codex/skills/requesting-code-review/code-reviewer.md index 3c427c9..525e4b4 100644 --- a/codex/skills/requesting-code-review/code-reviewer.md +++ b/codex/skills/requesting-code-review/code-reviewer.md @@ -1,111 +1,133 @@ -# Code Review Agent +# Code Reviewer Prompt Template -You are reviewing code changes for production readiness. +Use this template when dispatching a code reviewer subagent. -**Your task:** -1. Review {WHAT_WAS_IMPLEMENTED} -2. Compare against {PLAN_OR_REQUIREMENTS} -3. Check code quality, architecture, testing -4. Categorize issues by severity -5. Assess production readiness +**Purpose:** Review completed work against requirements and code quality standards before it cascades into more work. -## What Was Implemented +``` +Task tool (general-purpose): + description: "Review code changes" + prompt: | + You are a Senior Code Reviewer with expertise in software architecture, + design patterns, and best practices. Your job is to review completed work + against its plan or requirements and identify issues before they cascade. -{DESCRIPTION} + ## What Was Implemented -## Requirements/Plan + {DESCRIPTION} -{PLAN_REFERENCE} + ## Requirements / Plan -## Git Range to Review + {PLAN_OR_REQUIREMENTS} -**Base:** {BASE_SHA} -**Head:** {HEAD_SHA} + ## Git Range to Review -```bash -git diff --stat {BASE_SHA}..{HEAD_SHA} -git diff {BASE_SHA}..{HEAD_SHA} + **Base:** {BASE_SHA} + **Head:** {HEAD_SHA} + + ```bash + git diff --stat {BASE_SHA}..{HEAD_SHA} + git diff {BASE_SHA}..{HEAD_SHA} + ``` + + ## What to Check + + **Plan alignment:** + - Does the implementation match the plan / requirements? + - Are deviations justified improvements, or problematic departures? + - Is all planned functionality present? + + **Code quality:** + - Clean separation of concerns? + - Proper error handling? + - Type safety where applicable? + - DRY without premature abstraction? + - Edge cases handled? + + **Architecture:** + - Sound design decisions? + - Reasonable scalability and performance? + - Security concerns? + - Integrates cleanly with surrounding code? + + **Testing:** + - Tests verify real behavior, not mocks? + - Edge cases covered? + - Integration tests where they matter? + - All tests passing? + + **Production readiness:** + - Migration strategy if schema changed? + - Backward compatibility considered? + - Documentation complete? + - No obvious bugs? + + ## Calibration + + Categorize issues by actual severity. Not everything is Critical. + Acknowledge what was done well before listing issues — accurate praise + helps the implementer trust the rest of the feedback. + + If you find significant deviations from the plan, flag them specifically + so the implementer can confirm whether the deviation was intentional. + If you find issues with the plan itself rather than the implementation, + say so. + + ## Output Format + + ### Strengths + [What's well done? Be specific.] + + ### Issues + + #### Critical (Must Fix) + [Bugs, security issues, data loss risks, broken functionality] + + #### Important (Should Fix) + [Architecture problems, missing features, poor error handling, test gaps] + + #### Minor (Nice to Have) + [Code style, optimization opportunities, documentation polish] + + For each issue: + - File:line reference + - What's wrong + - Why it matters + - How to fix (if not obvious) + + ### Recommendations + [Improvements for code quality, architecture, or process] + + ### Assessment + + **Ready to merge?** [Yes | No | With fixes] + + **Reasoning:** [1-2 sentence technical assessment] + + ## Critical Rules + + **DO:** + - Categorize by actual severity + - Be specific (file:line, not vague) + - Explain WHY each issue matters + - Acknowledge strengths + - Give a clear verdict + + **DON'T:** + - Say "looks good" without checking + - Mark nitpicks as Critical + - Give feedback on code you didn't actually read + - Be vague ("improve error handling") + - Avoid giving a clear verdict ``` -## Review Checklist +**Placeholders:** +- `{DESCRIPTION}` — brief summary of what was built +- `{PLAN_OR_REQUIREMENTS}` — what it should do (plan file path, task text, or requirements) +- `{BASE_SHA}` — starting commit +- `{HEAD_SHA}` — ending commit -**Code Quality:** -- Clean separation of concerns? -- Proper error handling? -- Type safety (if applicable)? -- DRY principle followed? -- Edge cases handled? - -**Architecture:** -- Sound design decisions? -- Scalability considerations? -- Performance implications? -- Security concerns? - -**Testing:** -- Tests actually test logic (not mocks)? -- Edge cases covered? -- Integration tests where needed? -- All tests passing? - -**Requirements:** -- All plan requirements met? -- Implementation matches spec? -- No scope creep? -- Breaking changes documented? - -**Production Readiness:** -- Migration strategy (if schema changes)? -- Backward compatibility considered? -- Documentation complete? -- No obvious bugs? - -## Output Format - -### Strengths -[What's well done? Be specific.] - -### Issues - -#### Critical (Must Fix) -[Bugs, security issues, data loss risks, broken functionality] - -#### Important (Should Fix) -[Architecture problems, missing features, poor error handling, test gaps] - -#### Minor (Nice to Have) -[Code style, optimization opportunities, documentation improvements] - -**For each issue:** -- File:line reference -- What's wrong -- Why it matters -- How to fix (if not obvious) - -### Recommendations -[Improvements for code quality, architecture, or process] - -### Assessment - -**Ready to merge?** [Yes/No/With fixes] - -**Reasoning:** [Technical assessment in 1-2 sentences] - -## Critical Rules - -**DO:** -- Categorize by actual severity (not everything is Critical) -- Be specific (file:line, not vague) -- Explain WHY issues matter -- Acknowledge strengths -- Give clear verdict - -**DON'T:** -- Say "looks good" without checking -- Mark nitpicks as Critical -- Give feedback on code you didn't review -- Be vague ("improve error handling") -- Avoid giving a clear verdict +**Reviewer returns:** Strengths, Issues (Critical / Important / Minor), Recommendations, Assessment ## Example Output diff --git a/codex/skills/subagent-driven-development/SKILL.md b/codex/skills/subagent-driven-development/SKILL.md index 5150b18..ea7ac8f 100644 --- a/codex/skills/subagent-driven-development/SKILL.md +++ b/codex/skills/subagent-driven-development/SKILL.md @@ -11,6 +11,8 @@ Execute plan by dispatching fresh subagent per task, with two-stage review after **Core principle:** Fresh subagent per task + two-stage review (spec then quality) = high quality, fast iteration +**Continuous execution:** Do not pause to check in with your human partner between tasks. Execute all tasks from the plan without stopping. The only reasons to stop are: BLOCKED status you cannot resolve, ambiguity that genuinely prevents progress, or all tasks complete. "Should I continue?" prompts and progress summaries waste their time — they asked you to execute the plan, so execute it. + ## When to Use ```dot @@ -265,7 +267,7 @@ Done! ## Integration **Required workflow skills:** -- **superpowers:using-git-worktrees** - REQUIRED: Set up isolated workspace before starting +- **superpowers:using-git-worktrees** - Ensures isolated workspace (creates one or verifies existing) - **superpowers:writing-plans** - Creates the plan this skill executes - **superpowers:requesting-code-review** - Code review template for reviewer subagents - **superpowers:finishing-a-development-branch** - Complete development after all tasks diff --git a/codex/skills/subagent-driven-development/code-quality-reviewer-prompt.md b/codex/skills/subagent-driven-development/code-quality-reviewer-prompt.md index a04201a..51f901a 100644 --- a/codex/skills/subagent-driven-development/code-quality-reviewer-prompt.md +++ b/codex/skills/subagent-driven-development/code-quality-reviewer-prompt.md @@ -7,14 +7,13 @@ Use this template when dispatching a code quality reviewer subagent. **Only dispatch after spec compliance review passes.** ``` -Task tool (superpowers:code-reviewer): +Task tool (general-purpose): Use template at requesting-code-review/code-reviewer.md - WHAT_WAS_IMPLEMENTED: [from implementer's report] + DESCRIPTION: [task summary, from implementer's report] PLAN_OR_REQUIREMENTS: Task N from [plan-file] BASE_SHA: [commit before task] HEAD_SHA: [current commit] - DESCRIPTION: [task summary] ``` **In addition to standard code quality concerns, the reviewer should check:** diff --git a/codex/skills/systematic-debugging/CREATION-LOG.md b/codex/skills/systematic-debugging/CREATION-LOG.md index 024d00a..9aa0309 100644 --- a/codex/skills/systematic-debugging/CREATION-LOG.md +++ b/codex/skills/systematic-debugging/CREATION-LOG.md @@ -4,7 +4,7 @@ Reference example of extracting, structuring, and bulletproofing a critical skil ## Source Material -Extracted debugging framework from `/Users/jesse/.claude/CLAUDE.md`: +Extracted debugging framework from `~/.claude/CLAUDE.md`: - 4-phase systematic process (Investigation → Pattern Analysis → Hypothesis → Implementation) - Core mandate: ALWAYS find root cause, NEVER fix symptoms - Rules designed to resist time pressure and rationalization diff --git a/codex/skills/systematic-debugging/root-cause-tracing.md b/codex/skills/systematic-debugging/root-cause-tracing.md index 9484774..12ef522 100644 --- a/codex/skills/systematic-debugging/root-cause-tracing.md +++ b/codex/skills/systematic-debugging/root-cause-tracing.md @@ -33,7 +33,7 @@ digraph when_to_use { ### 1. Observe the Symptom ``` -Error: git init failed in /Users/jesse/project/packages/core +Error: git init failed in ~/project/packages/core ``` ### 2. Find Immediate Cause diff --git a/codex/skills/using-git-worktrees/SKILL.md b/codex/skills/using-git-worktrees/SKILL.md index e153843..134d371 100644 --- a/codex/skills/using-git-worktrees/SKILL.md +++ b/codex/skills/using-git-worktrees/SKILL.md @@ -1,104 +1,117 @@ --- name: using-git-worktrees -description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification +description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback --- # Using Git Worktrees ## Overview -Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching. +Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available. -**Core principle:** Systematic directory selection + safety verification = reliable isolation. +**Core principle:** Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness. **Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace." -## Directory Selection Process +## Step 0: Detect Existing Isolation -Follow this priority order: - -### 1. Check Existing Directories +**Before creating anything, check if you are already in an isolated workspace.** ```bash -# Check in priority order -ls -d .worktrees 2>/dev/null # Preferred (hidden) -ls -d worktrees 2>/dev/null # Alternative +GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P) +GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P) +BRANCH=$(git branch --show-current) ``` -**If found:** Use that directory. If both exist, `.worktrees` wins. - -### 2. Check CLAUDE.md +**Submodule guard:** `GIT_DIR != GIT_COMMON` is also true inside git submodules. Before concluding "already in a worktree," verify you are not in a submodule: ```bash -grep -i "worktree.*director" CLAUDE.md 2>/dev/null +# If this returns a path, you're in a submodule, not a worktree — treat as normal repo +git rev-parse --show-superproject-working-tree 2>/dev/null ``` -**If preference specified:** Use it without asking. +**If `GIT_DIR != GIT_COMMON` (and not a submodule):** You are already in a linked worktree. Skip to Step 3 (Project Setup). Do NOT create another worktree. -### 3. Ask User +Report with branch state: +- On a branch: "Already in isolated workspace at `` on branch ``." +- Detached HEAD: "Already in isolated workspace at `` (detached HEAD, externally managed). Branch creation needed at finish time." -If no directory exists and no CLAUDE.md preference: +**If `GIT_DIR == GIT_COMMON` (or in a submodule):** You are in a normal repo checkout. -``` -No worktree directory found. Where should I create worktrees? +Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree: -1. .worktrees/ (project-local, hidden) -2. ~/.config/superpowers/worktrees// (global location) +> "Would you like me to set up an isolated worktree? It protects your current branch from changes." -Which would you prefer? -``` +Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 3. -## Safety Verification +## Step 1: Create Isolated Workspace -### For Project-Local Directories (.worktrees or worktrees) +**You have two mechanisms. Try them in this order.** + +### 1a. Native Worktree Tools (preferred) + +The user has asked for an isolated workspace (Step 0 consent). Do you already have a way to create a worktree? It might be a tool with a name like `EnterWorktree`, `WorktreeCreate`, a `/worktree` command, or a `--worktree` flag. If you do, use it and skip to Step 3. + +Native tools handle directory placement, branch creation, and cleanup automatically. Using `git worktree add` when you have a native tool creates phantom state your harness can't see or manage. + +Only proceed to Step 1b if you have no native worktree tool available. + +### 1b. Git Worktree Fallback + +**Only use this if Step 1a does not apply** — you have no native worktree tool available. Create a worktree manually using git. + +#### Directory Selection + +Follow this priority order. Explicit user preference always beats observed filesystem state. + +1. **Check your instructions for a declared worktree directory preference.** If the user has already specified one, use it without asking. + +2. **Check for an existing project-local worktree directory:** + ```bash + ls -d .worktrees 2>/dev/null # Preferred (hidden) + ls -d worktrees 2>/dev/null # Alternative + ``` + If found, use it. If both exist, `.worktrees` wins. + +3. **Check for an existing global directory:** + ```bash + project=$(basename "$(git rev-parse --show-toplevel)") + ls -d ~/.config/superpowers/worktrees/$project 2>/dev/null + ``` + If found, use it (backward compatibility with legacy global path). + +4. **If there is no other guidance available**, default to `.worktrees/` at the project root. + +#### Safety Verification (project-local directories only) **MUST verify directory is ignored before creating worktree:** ```bash -# Check if directory is ignored (respects local, global, and system gitignore) git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null ``` -**If NOT ignored:** - -Per Jesse's rule "Fix broken things immediately": -1. Add appropriate line to .gitignore -2. Commit the change -3. Proceed with worktree creation +**If NOT ignored:** Add to .gitignore, commit the change, then proceed. **Why critical:** Prevents accidentally committing worktree contents to repository. -### For Global Directory (~/.config/superpowers/worktrees) +Global directories (`~/.config/superpowers/worktrees/`) need no verification. -No .gitignore verification needed - outside project entirely. - -## Creation Steps - -### 1. Detect Project Name +#### Create the Worktree ```bash project=$(basename "$(git rev-parse --show-toplevel)") -``` -### 2. Create Worktree +# Determine path based on chosen location +# For project-local: path="$LOCATION/$BRANCH_NAME" +# For global: path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME" -```bash -# Determine full path -case $LOCATION in - .worktrees|worktrees) - path="$LOCATION/$BRANCH_NAME" - ;; - ~/.config/superpowers/worktrees/*) - path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME" - ;; -esac - -# Create worktree with new branch git worktree add "$path" -b "$BRANCH_NAME" cd "$path" ``` -### 3. Run Project Setup +**Sandbox fallback:** If `git worktree add` fails with a permission error (sandbox denial), tell the user the sandbox blocked worktree creation and you're working in the current directory instead. Then run setup and baseline tests in place. + +## Step 3: Project Setup Auto-detect and run appropriate setup: @@ -117,23 +130,20 @@ if [ -f pyproject.toml ]; then poetry install; fi if [ -f go.mod ]; then go mod download; fi ``` -### 4. Verify Clean Baseline +## Step 4: Verify Clean Baseline -Run tests to ensure worktree starts clean: +Run tests to ensure workspace starts clean: ```bash -# Examples - use project-appropriate command -npm test -cargo test -pytest -go test ./... +# Use project-appropriate command +npm test / cargo test / pytest / go test ./... ``` **If tests fail:** Report failures, ask whether to proceed or investigate. **If tests pass:** Report ready. -### 5. Report Location +### Report ``` Worktree ready at @@ -145,16 +155,32 @@ Ready to implement | Situation | Action | |-----------|--------| +| Already in linked worktree | Skip creation (Step 0) | +| In a submodule | Treat as normal repo (Step 0 guard) | +| Native worktree tool available | Use it (Step 1a) | +| No native tool | Git worktree fallback (Step 1b) | | `.worktrees/` exists | Use it (verify ignored) | | `worktrees/` exists | Use it (verify ignored) | | Both exist | Use `.worktrees/` | -| Neither exists | Check CLAUDE.md → Ask user | +| Neither exists | Check instruction file, then default `.worktrees/` | +| Global path exists | Use it (backward compat) | | Directory not ignored | Add to .gitignore + commit | +| Permission error on create | Sandbox fallback, work in place | | Tests fail during baseline | Report failures + ask | | No package.json/Cargo.toml | Skip dependency install | ## Common Mistakes +### Fighting the harness + +- **Problem:** Using `git worktree add` when the platform already provides isolation +- **Fix:** Step 0 detects existing isolation. Step 1a defers to native tools. + +### Skipping detection + +- **Problem:** Creating a nested worktree inside an existing one +- **Fix:** Always run Step 0 before creating anything + ### Skipping ignore verification - **Problem:** Worktree contents get tracked, pollute git status @@ -163,56 +189,27 @@ Ready to implement ### Assuming directory location - **Problem:** Creates inconsistency, violates project conventions -- **Fix:** Follow priority: existing > CLAUDE.md > ask +- **Fix:** Follow priority: existing > global legacy > instruction file > default ### Proceeding with failing tests - **Problem:** Can't distinguish new bugs from pre-existing issues - **Fix:** Report failures, get explicit permission to proceed -### Hardcoding setup commands - -- **Problem:** Breaks on projects using different tools -- **Fix:** Auto-detect from project files (package.json, etc.) - -## Example Workflow - -``` -You: I'm using the using-git-worktrees skill to set up an isolated workspace. - -[Check .worktrees/ - exists] -[Verify ignored - git check-ignore confirms .worktrees/ is ignored] -[Create worktree: git worktree add .worktrees/auth -b feature/auth] -[Run npm install] -[Run npm test - 47 passing] - -Worktree ready at /Users/jesse/myproject/.worktrees/auth -Tests passing (47 tests, 0 failures) -Ready to implement auth feature -``` - ## Red Flags **Never:** +- Create a worktree when Step 0 detects existing isolation +- Use `git worktree add` when you have a native worktree tool (e.g., `EnterWorktree`). This is the #1 mistake — if you have it, use it. +- Skip Step 1a by jumping straight to Step 1b's git commands - Create worktree without verifying it's ignored (project-local) - Skip baseline test verification - Proceed with failing tests without asking -- Assume directory location when ambiguous -- Skip CLAUDE.md check **Always:** -- Follow directory priority: existing > CLAUDE.md > ask +- Run Step 0 detection first +- Prefer native tools over git fallback +- Follow directory priority: existing > global legacy > instruction file > default - Verify directory is ignored for project-local - Auto-detect and run project setup - Verify clean test baseline - -## Integration - -**Called by:** -- **brainstorming** (Phase 4) - REQUIRED when design is approved and implementation follows -- **subagent-driven-development** - REQUIRED before executing any tasks -- **executing-plans** - REQUIRED before executing any tasks -- Any skill needing isolated workspace - -**Pairs with:** -- **finishing-a-development-branch** - REQUIRED for cleanup after work complete diff --git a/codex/skills/using-superpowers/references/codex-tools.md b/codex/skills/using-superpowers/references/codex-tools.md index 539b2b1..f50d40d 100644 --- a/codex/skills/using-superpowers/references/codex-tools.md +++ b/codex/skills/using-superpowers/references/codex-tools.md @@ -4,9 +4,9 @@ Skills use Claude Code tool names. When you encounter these in a skill, use your | Skill references | Codex equivalent | |-----------------|------------------| -| `Task` tool (dispatch subagent) | `spawn_agent` (see [Named agent dispatch](#named-agent-dispatch)) | +| `Task` tool (dispatch subagent) | `spawn_agent` (see [Subagent dispatch requires multi-agent support](#subagent-dispatch-requires-multi-agent-support)) | | Multiple `Task` calls (parallel) | Multiple `spawn_agent` calls | -| Task returns result | `wait` | +| Task returns result | `wait_agent` | | Task completes automatically | `close_agent` to free slot | | `TodoWrite` (task tracking) | `update_plan` | | `Skill` tool (invoke a skill) | Skills load natively — just follow the instructions | @@ -22,53 +22,12 @@ Add to your Codex config (`~/.codex/config.toml`): multi_agent = true ``` -This enables `spawn_agent`, `wait`, and `close_agent` for skills like `dispatching-parallel-agents` and `subagent-driven-development`. +This enables `spawn_agent`, `wait_agent`, and `close_agent` for skills like `dispatching-parallel-agents` and `subagent-driven-development`. -## Named agent dispatch - -Claude Code skills reference named agent types like `superpowers:code-reviewer`. -Codex does not have a named agent registry — `spawn_agent` creates generic agents -from built-in roles (`default`, `explorer`, `worker`). - -When a skill says to dispatch a named agent type: - -1. Find the agent's prompt file (e.g., `agents/code-reviewer.md` or the skill's - local prompt template like `code-quality-reviewer-prompt.md`) -2. Read the prompt content -3. Fill any template placeholders (`{BASE_SHA}`, `{WHAT_WAS_IMPLEMENTED}`, etc.) -4. Spawn a `worker` agent with the filled content as the `message` - -| Skill instruction | Codex equivalent | -|-------------------|------------------| -| `Task tool (superpowers:code-reviewer)` | `spawn_agent(agent_type="worker", message=...)` with `code-reviewer.md` content | -| `Task tool (general-purpose)` with inline prompt | `spawn_agent(message=...)` with the same prompt | - -### Message framing - -The `message` parameter is user-level input, not a system prompt. Structure it -for maximum instruction adherence: - -``` -Your task is to perform the following. Follow the instructions below exactly. - - -[filled prompt content from the agent's .md file] - - -Execute this now. Output ONLY the structured response following the format -specified in the instructions above. -``` - -- Use task-delegation framing ("Your task is...") rather than persona framing ("You are...") -- Wrap instructions in XML tags — the model treats tagged blocks as authoritative -- End with an explicit execution directive to prevent summarization of the instructions - -### When this workaround can be removed - -This approach compensates for Codex's plugin system not yet supporting an `agents` -field in `plugin.json`. When `RawPluginManifest` gains an `agents` field, the -plugin can symlink to `agents/` (mirroring the existing `skills/` symlink) and -skills can dispatch named agent types directly. +Legacy note: Codex builds before `rust-v0.115.0` exposed spawned-agent +waiting as `wait`. Current Codex uses `wait_agent` for spawned agents. The +`wait` name now belongs to code-mode `exec/wait`, which resumes a yielded exec +cell by `cell_id`; it is not the spawned-agent result tool. ## Environment Detection diff --git a/codex/skills/using-superpowers/references/copilot-tools.md b/codex/skills/using-superpowers/references/copilot-tools.md index 4316cdb..ae3cf5a 100644 --- a/codex/skills/using-superpowers/references/copilot-tools.md +++ b/codex/skills/using-superpowers/references/copilot-tools.md @@ -12,23 +12,13 @@ Skills use Claude Code tool names. When you encounter these in a skill, use your | `Glob` (search files by name) | `glob` | | `Skill` tool (invoke a skill) | `skill` | | `WebFetch` | `web_fetch` | -| `Task` tool (dispatch subagent) | `task` (see [Agent types](#agent-types)) | +| `Task` tool (dispatch subagent) | `task` with `agent_type: "general-purpose"` or `"explore"` | | Multiple `Task` calls (parallel) | Multiple `task` calls | | Task status/output | `read_agent`, `list_agents` | | `TodoWrite` (task tracking) | `sql` with built-in `todos` table | | `WebSearch` | No equivalent — use `web_fetch` with a search engine URL | | `EnterPlanMode` / `ExitPlanMode` | No equivalent — stay in the main session | -## Agent types - -Copilot CLI's `task` tool accepts an `agent_type` parameter: - -| Claude Code agent | Copilot CLI equivalent | -|-------------------|----------------------| -| `general-purpose` | `"general-purpose"` | -| `Explore` | `"explore"` | -| Named plugin agents (e.g. `superpowers:code-reviewer`) | Discovered automatically from installed plugins | - ## Async shell sessions Copilot CLI supports persistent async shell sessions, which have no direct Claude Code equivalent: diff --git a/codex/skills/using-superpowers/references/gemini-tools.md b/codex/skills/using-superpowers/references/gemini-tools.md index f869803..91ef404 100644 --- a/codex/skills/using-superpowers/references/gemini-tools.md +++ b/codex/skills/using-superpowers/references/gemini-tools.md @@ -14,11 +14,29 @@ Skills use Claude Code tool names. When you encounter these in a skill, use your | `Skill` tool (invoke a skill) | `activate_skill` | | `WebSearch` | `google_web_search` | | `WebFetch` | `web_fetch` | -| `Task` tool (dispatch subagent) | No equivalent — Gemini CLI does not support subagents | +| `Task` tool (dispatch subagent) | `@agent-name` (see [Subagent support](#subagent-support)) | -## No subagent support +## Subagent support -Gemini CLI has no equivalent to Claude Code's `Task` tool. Skills that rely on subagent dispatch (`subagent-driven-development`, `dispatching-parallel-agents`) will fall back to single-session execution via `executing-plans`. +Gemini CLI supports subagents natively via the `@` syntax. Use the built-in `@generalist` agent to dispatch any task — it has access to all tools and follows the prompt you provide. + +When a skill says to dispatch a named agent type, use `@generalist` with the full prompt from the skill's prompt template: + +| Skill instruction | Gemini CLI equivalent | +|-------------------|----------------------| +| `Task tool (superpowers:implementer)` | `@generalist` with the filled `implementer-prompt.md` template | +| `Task tool (superpowers:spec-reviewer)` | `@generalist` with the filled `spec-reviewer-prompt.md` template | +| `Task tool (superpowers:code-reviewer)` | `@code-reviewer` (bundled agent) or `@generalist` with the filled review prompt | +| `Task tool (superpowers:code-quality-reviewer)` | `@generalist` with the filled `code-quality-reviewer-prompt.md` template | +| `Task tool (general-purpose)` with inline prompt | `@generalist` with your inline prompt | + +### Prompt filling + +Skills provide prompt templates with placeholders like `{WHAT_WAS_IMPLEMENTED}` or `[FULL TEXT of task]`. Fill all placeholders and pass the complete prompt as the message to `@generalist`. The prompt template itself contains the agent's role, review criteria, and expected output format — `@generalist` will follow it. + +### Parallel dispatch + +Gemini CLI supports parallel subagent dispatch. When a skill asks you to dispatch multiple independent subagent tasks in parallel, request all of those `@generalist` or named subagent tasks together in the same prompt. Keep dependent tasks sequential, but do not serialize independent subagent tasks just to preserve a simpler history. ## Additional Gemini CLI tools diff --git a/codex/skills/writing-plans/SKILL.md b/codex/skills/writing-plans/SKILL.md index 0d9c00b..847412e 100644 --- a/codex/skills/writing-plans/SKILL.md +++ b/codex/skills/writing-plans/SKILL.md @@ -13,7 +13,7 @@ Assume they are a skilled developer, but know almost nothing about our toolset o **Announce at start:** "I'm using the writing-plans skill to create the implementation plan." -**Context:** This should be run in a dedicated worktree (created by brainstorming skill). +**Context:** If working in an isolated worktree, it should have been created via the `superpowers:using-git-worktrees` skill at execution time. **Save plans to:** `docs/superpowers/plans/YYYY-MM-DD-.md` - (User preferences for plan location override this default)