lewibs/dark-factory/branch-drift-guard

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.

After a worker agent returns in an orchestrator, verify the feature branch is ahead of main to detect cases where the worker committed to the wrong branch or failed to commit at all.

Install

npx vskill@latest install lewibs/dark-factory/branch-drift-guard

SKILL.md

The same SKILL.md was published earlier as lewibs/dark-factory/branch-drift-guard.

When to use

Immediately after any worker agent (feature-agent, debugger-agent, repair-implementation-agent) returns control to the dark-factory orchestrator, and before proceeding to code review or PR steps.

This guard catches the class of bug where a sub-agent runs git commit without an explicit -C WORK_DIR or --work-tree flag and the commit lands on the wrong branch (e.g., main) because the CWD defaults to the parent worktree.

Steps

  1. After the worker agent returns, determine the branch reference. For new branches this is always "feature/" + taskName; when reusing an existing PR the branch may have any prefix (bugfix/, plain slug, etc.):

`` branchRef = USE_EXISTING ? EXISTING_BRANCH : ("feature/" + taskName) ``

  1. Run a scoped git log to check for commits ahead of main:

``bash git -C "$WORK_DIR" log main..<branchRef> --oneline 2>&1 ``

  1. If the output is empty (no commits ahead), the worker either committed to the wrong branch or did not commit at all. Do not proceed:

`` rm -f /tmp/dark-factory-work-dir run cleanup(WORK_DIR) report error: "Branch-drift guard failed: <branchRef> has no commits ahead of main. The worker agent may have committed to the wrong branch or failed to commit at all. Halting before code review to prevent opening a PR with no changes." STOP ``

  1. If the output is non-empty, the feature branch has the expected commits — continue to code review.

Notes

  • Always use git -C "$WORK_DIR" (not a bare git) so the command targets the isolated worktree, not whatever the orchestrator's CWD happens to be.
  • This guard should run even when the worker returns status == "done" — a successful return does not guarantee the commit landed on the correct branch.
  • The root cause of branch drift is sub-agents issuing git commands without -C WORK_DIR, causing git to resolve the repo from the ambient shell CWD, which may point to the main worktree. See skill git-c-worktree-subagent for the companion fix.
  • If the project uses a different default branch name (e.g., master), substitute it for main in the log range.
  • When reusing an existing PR branch the branch name will not have the feature/ prefix — always use the full branchRef variable, not a hardcoded "feature/" + taskName interpolation. Hardcoding the prefix causes the drift guard to check the wrong branch and always report failure.

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/branch-drift-guard/badge)](https://verified-skill.com/skills/lewibs/dark-factory/branch-drift-guard)

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