flock
Skill0 starsChanged 46 days agoMITView on GitHub
Control Herdr (terminal multiplexer for coding agents) and manage git worktrees through it: spawn a worktree workspace with an agent and task, show a status overview of worktrees/agents/PRs, clean up merged or stale worktrees, rebase/sync a worktree, collect an agent's results, open a PR. Use when the user mentions Herdr or flock, or asks to manage worktrees or run parallel agents per branch while inside Herdr. Every state-changing action is confirmed with the user first. Requires HERDR_ENV=1.
- Commits and pushes
In this repository3 other files it gives its agents.
- keep-diggingSkill
- semantic-reviewSkill
- tell-my-managerSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 2 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
If HERDR_ENV isn't 1, say that you're not running inside Herdr, and stop.
- Very specific: line 42
Use AskUserQuestion if you have it.
- Distinctive: line 45
If the user says no, or doesn't answer: don't run it.
- Very specific: line 52
Use --current for the calling pane, or pass explicit IDs.
- Very specific: line 56
Use pane commands for shells, tests, and servers: pane run, pane wait-output --match … --timeout …, and pane read --source recent-unwrapped.
- Very specific: line 57
Use agent commands for recognized agents: agent start <name> --kind <k> --pane <id>, agent prompt <name> "…" --wait --timeout <ms>, agent …
- Very specific: line 66
Check herdr pane layout --current to choose the direction.
- Distinctive: line 77
Use worktrees when the user asks for isolation, for parallel work on several branches, or explicitly for a worktree.
- Very specific: line 89
Always dry-run first, and show the plan's display[] lines.
- Very specific: line 95
Never remove the primary checkout (is_linked_worktree: false).
- Very specific: line 96
Never touch a worktree whose agent is working or blocked without explicit consent.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
flock
flock manages Herdr workspaces, panes, and agents, plus the git worktrees they run in: one branch per worktree, one agent per worktree.
0. Preflight
test "${HERDR_ENV:-}" = 1 && herdr status- If
HERDR_ENVisn't1, say that you're not running inside Herdr, and stop. - The installed binary is the authority for syntax. Run
herdr <group>(e.g.herdr worktree,herdr agent) to print a command group's usage. Never run bareherdr, which opens the TUI. Never probe a mutating subcommand by leaving out its arguments: defaults execute. - Most commands return JSON. Read IDs from the responses; never predict them.
- Scripts are in
scripts/next to this file. Detailed flows are inreferences/worktrees.md, and the full upstream Herdr guide (panes, agents, reading output, SSH machines) is inreferences/herdr-core.md. Read the relevant reference before running a workflow.
1. Confirmation gate (always applies)
Ask the user before every state-changing action, every time. The user asking for the overall task ("clean up my worktrees") is not approval for the individual commands.
Run freely (read-only):
herdr … list|get|read|layout|current|status,herdr agent explain.git status|log|diff|show|branch --list|worktree list|rev-list|merge-base,git fetch.git fetchchanges nothing in the working tree. Still, mention it the first time you use it in a repo.
gh pr list|view.scripts/wt-status.sh,scripts/wt-cleanup-candidates.sh, andscripts/wt-spawn.shwithout--yes, which is a dry run.
Confirm first (everything else, including):
- Creating things:
worktree create|open,workspace|tab create,pane split,agent start,wt-spawn.sh --yes. - Sending input:
agent prompt,agent send-keys,pane run|send-text|send-keys. That includes answering another agent's approval or trust dialog. - Removing things:
worktree remove,workspace|tab|pane close,git branch -d|-D,git worktree prune,git stash drop,git clean. - Changing history or state:
git rebase|merge|reset|checkout|switch|cherry-pick|stash|commitin any worktree. - Going outward:
git push(any form),gh pr create|merge|close|edit, and remote branch deletion. - Anything with
--force,-D, or--trust-repository.
How to ask:
- Show the exact command(s) and their target: repo, branch, path, workspace or pane ID. For destructive steps, also show what would be lost, e.g. "3 untracked files" or "2 unpushed commits".
- Use
AskUserQuestionif you have it; otherwise ask in plain text and end your turn. For batches (several worktrees, several spawns), let the user pick a subset with a multi-select. - An approval covers only the commands you showed. It doesn't carry over to later steps, retries, other worktrees, or "the same thing again later".
- Escalations need a new confirmation. For example:
branch -dfails, and you propose-D;worktree removehits a dirty tree, and you propose--force; a rebase conflicts, and you propose--abortor a resolution. - If the user says no, or doesn't answer: don't run it. Report where things stand.
2. Herdr basics
- IDs
- IDs are opaque handles: workspace
w1, tabw1:t1, panew1:p1. - Herdr injects your own context as
$HERDR_WORKSPACE_ID,$HERDR_TAB_ID, and$HERDR_PANE_ID. - Use
--currentfor the calling pane, or pass explicit IDs. Never rely on the UI-focused pane; it may belong to the user.
- IDs are opaque handles: workspace
- Focus
- Background work always uses
--no-focus. Focus something (workspace focus,agent focus) only when the user asks.
- Background work always uses
- Panes versus agents
- Use pane commands for shells, tests, and servers:
pane run,pane wait-output --match … --timeout …, andpane read --source recent-unwrapped. - Use agent commands for recognized agents:
agent start <name> --kind <k> --pane <id>,agent prompt <name> "…" --wait --timeout <ms>,agent wait,agent read, andagent get. - Agent names match
[a-z][a-z0-9_-]{0,31}.
- Use pane commands for shells, tests, and servers:
- Agent states
idleanddonemean the agent is ready for input.blockedmeans it's showing an approval or question UI. Read it, show it to the user, and let them decide.unknowndoesn't mean done.- A timeout or
agent_prompt_stalleddoesn't prove the prompt wasn't delivered. Never re-send blindly. Read the agent's screen first.
- Sibling panes
- Without worktree mode, start extra agents or commands in a sibling pane:
herdr pane split --current --direction right|down --cwd "$PWD" --no-focus. - Check
herdr pane layout --currentto choose the direction.
- Without worktree mode, start extra agents or commands in a sibling pane:
- Never
herdr server stop.- Killing the Herdr process.
- Closing workspaces, tabs, or panes you didn't create, unless the user asks and confirms.
workspace close --group.
For anything beyond this, such as read sources, alternate-screen output, pane moves, or --machine, see references/herdr-core.md.
3. Worktree workflows
Use worktrees when the user asks for isolation, for parallel work on several branches, or explicitly for a worktree. Otherwise, default to a sibling pane in the current tab and cwd.
| Goal | Tool | Gate |
| Status: worktrees, workspaces, agents, dirty and ahead/behind, PRs | scripts/wt-status.sh [--cwd <repo>] [--json] [--no-pr] | free |
| Spawn: worktree, then an agent, then an optional task | scripts/wt-spawn.sh --cwd <repo> --branch <b> [--base <ref>] --kind <k> --name <n> [--prompt "…" --wait --timeout <ms>] [-- <agent-args>] | dry run first; --yes after approval |
| Cleanup: merged or stale worktrees | scripts/wt-cleanup-candidates.sh [--cwd <repo>], then run the approved commands[] | multi-select approval per worktree |
| Sync: rebase or merge base into a worktree | git -C <path> fetch, then a confirmed rebase origin/<base> | confirm; stop on conflicts |
| Hand-back: collect results, open a PR | agent read, plus git log/diff <base>...HEAD, then a confirmed push and gh pr create | confirm push and PR separately |
Key rules (details in references/worktrees.md):
- Spawn
- Always dry-run first, and show the plan's
display[]lines. - A new worktree path usually makes the agent show a startup trust dialog. That surfaces as
agent_not_ready. Show the dialog to the user; never accept it yourself.
- Always dry-run first, and show the plan's
- Remove
herdr worktree removekeeps the branch. Deleting the branch is a separate, confirmed step.- It refuses dirty trees. Treat that refusal as a stop, not as a reason to retry with
--force.
- Protected
- Never remove the primary checkout (
is_linked_worktree: false). - Never touch a worktree whose agent is
workingorblockedwithout explicit consent.
- Never remove the primary checkout (
- Weak signal
no_unique_commitsalone doesn't prove the work was merged. The branch may never have had a commit. Rely onpr_mergedas the strong signal.
- Report back
- Once a workflow finishes, report what changed: IDs, paths, branches, and what's left.
- List anything you created as a side effect. For example,
worktree createmay open the primary checkout as a new workspace.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

