lewibs/dark-factory/capture-project-dir-before-worktree

Claude Code and agent skill by lewibs/dark-factory

Trust tier 3
  • community
Source check pending

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-worktree

SKILL.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

  1. Before prep-feature-dir.sh is called (while the shell cwd is still the real project root), capture PROJECT_DIR:

``bash PROJECT_DIR=$(git rev-parse --show-toplevel) ``

  1. Store PROJECT_DIR into brain.json at creation time so it is available in the cleanup step:

``json { "projectDir": "<PROJECT_DIR>", "workDir": "<WORK_DIR>", ... } ``

  1. 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" ... ``

  1. Never use brain.json.workDir as the base path for permanent files. The worktree at workDir is deleted by cleanup-worktree.sh, so any write to $workDir/foo after cleanup is silently lost.

Notes

  • brain.json.workDir and brain.json.projectDir serve different purposes: workDir is the ephemeral git worktree; projectDir is the permanent repo root that persists across sessions.
  • git rev-parse --show-toplevel must be run from the real project working directory, not from inside the worktree. Capture it in the same shell block that initializes brain.json, before cd-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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/lewibs/dark-factory/capture-project-dir-before-worktree/badge)](https://verified-skill.com/skills/lewibs/dark-factory/capture-project-dir-before-worktree)

Something wrong with this skill or its page? Tell us.