lewibs/dark-factory/capture-project-dir-before-worktree
Claude Code and agent skill by lewibs/dark-factory
- community
Checking that the SKILL.md file is still in the repository.
How to safely capture the real project root path before entering a worktree, so that files written at end-of-manufacture land in the permanent project directory rather than the (deleted) worktree.
Install
npx vskill@latest install lewibs/dark-factory/capture-project-dir-before-worktreeSKILL.md
The same SKILL.md was published earlier as lewibs/dark-factory/capture-project-dir-before-worktree.
When to use
Whenever a manufacture step needs to write a permanent file (metrics CSV, report, artifact, etc.) to the real project root at the end of a manufacture run — specifically in the cleanup step of dark-factory-agent, after sub-agents have run and before the worktree is deleted.
Steps
- Before
prep-feature-dir.shis called (while the shell cwd is still the real project root), capture PROJECT_DIR:
``bash PROJECT_DIR=$(git rev-parse --show-toplevel) ``
- Store PROJECT_DIR into brain.json at creation time so it is available in the cleanup step:
``json { "projectDir": "<PROJECT_DIR>", "workDir": "<WORK_DIR>", ... } ``
- In the cleanup step, read PROJECT_DIR from brain.json before deleting brain.json:
``bash PROJECT_DIR=$(jq -r '.projectDir' "$WORK_DIR/brain.json") python3 "${CLAUDE_PLUGIN_ROOT}/scripts/update-metrics.py" --csv "$PROJECT_DIR/metrics.csv" --brain "$WORK_DIR/brain.json" || true rm -f "$WORK_DIR/brain.json" bash "${CLAUDE_PLUGIN_ROOT}/agents/dark-factory/scripts/cleanup-worktree.sh" ... ``
- Never use
brain.json.workDiras the base path for permanent files. The worktree atworkDiris deleted bycleanup-worktree.sh, so any write to$workDir/fooafter cleanup is silently lost.
Notes
brain.json.workDirandbrain.json.projectDirserve different purposes:workDiris the ephemeral git worktree;projectDiris the permanent repo root that persists across sessions.git rev-parse --show-toplevelmust be run from the real project working directory, not from inside the worktree. Capture it in the same shell block that initializes brain.json, beforecd-ing into the worktree.- The allowed-tools list in dark-factory-agent's frontmatter must include
Bash(git rev-parse *)for this to work. - This pattern applies to any file that should persist after manufacture: metrics CSVs, changelog appends, deployment records, etc.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/capture-project-dir-before-worktree/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lewibs/dark-factory/capture-project-dir-before-worktree)