lewibs/dark-factory/subagent-brain-patch-pointer-fallback
Claude Code and agent skill by lewibs/dark-factory
- community
Checking that the SKILL.md file is still in the repository.
When a sub-agent writes brain-patch.json, it must resolve WORK_DIR via the /tmp/dark-factory-work-dir pointer file because $DARK_FACTORY_WORK_DIR is never propagated to sub-agent processes.
Install
npx vskill@latest install lewibs/dark-factory/subagent-brain-patch-pointer-fallbackSKILL.md
The same SKILL.md was published earlier as lewibs/dark-factory/subagent-brain-patch-pointer-fallback.
When to use
Every time a sub-agent (feature-agent, pr-agent, skill-update-agent, update-documentation-agent, debugger-agent, or any new agent added to the pipeline) needs to write brain-patch.json at the end of its run.
Do NOT use the bare $DARK_FACTORY_WORK_DIR approach without the pointer-file fallback. The env var is set by the orchestrator (dark-factory-agent) in one Bash subprocess and is never visible to sub-agents, which run in isolated processes.
The root cause
DARK_FACTORY_WORK_DIR is exported by the orchestrator inside a Bash tool call. That call's subprocess exits immediately after, taking the env var with it. Sub-agents launched later (via the Agent tool) run in their own fresh environment and never inherit the value.
/tmp/dark-factory-work-dir is written to disk by the orchestrator and survives across process boundaries, making it the correct resolution channel.
Steps
In every sub-agent's brain-patch.json write block, use this exact resolution sequence:
In pseudocode / shell:
Notes
- This pattern is required for ALL five existing brain-patch writers and any new sub-agent added to the pipeline.
- The pointer file is created by dark-factory-agent immediately after
brain.jsonis written (seebrain-hook-driven-stateskill, Step 2) and deleted during cleanup. - Hook scripts (pre/post tool-use) use the same pointer-file fallback on the bash side — see
claude-code-hook-env-isolationskill for the hook-specific pattern. - Never silently skip the write without first checking the pointer file — silent skips mean brain.json fields (
planFilePath,prUrl,docsWritten,skillsWritten,bugFiles) are never populated and the orchestrator cannot hand values between pipeline phases. - This skill covers
brain-patch.jsonwrites only. All other file writes (docs, skills, tmp scratch files) must also be anchored to WORK_DIR — see skillsubagent-workdir-file-isolation.
Security
- Security scanPassed, 95 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/subagent-brain-patch-pointer-fallback/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/subagent-brain-patch-pointer-fallback)