lever-init
Bootstrap this repo for agent-levers. Idempotent: only adds files. The one exception is §3 — when AGENTS.md exists but doesn't reference the lever skills, init appends a Workflow section pointing at them.
GitHub Copilot reads AGENTS.md natively; Claude Code (CLAUDE.md) and Gemini CLI (GEMINI.md) need a one-line @-import shim.
1. Pre-flight
Confirm the cwd is a git repo:
git rev-parse --is-inside-work-tree. If not, stop with"Blocked: not a git repository — run \git init` first."`Run
git status --porcelain. If non-empty, list dirty paths under aPre-existing changes:heading in the chat reply and proceed — init only adds files.Confirm
.agents/levers/is not git-ignored (handles negations, nested.gitignores, glob patterns, portable across Linux/macOS/Windows Git Bash):git check-ignore -q .agents/levers/.gitkeepExit
0means the path is ignored. Surface the offending line(s) withgrep -n '\.agents' .gitignoreand stop with a chat sentence naming the gitignored path.
2. Workspace skeleton
mkdir -p .agents/levers
3. AGENTS.md
AGENTS.md is the project's contract with its agents — voice, conventions, layout, workflow. Three cases:
- Missing. Write
templates/AGENTS.md(sibling of thisSKILL.md) verbatim. Surface in chat:"Wrote AGENTS.md from the lever-init skeleton — fill in the placeholders before running /lever-new." - Exists, mentions any of
/lever-new,/lever,/lever-status. No-op. The workflow is already wired. - Exists, no lever mention. Append a Workflow section pointing at
/lever-new,/lever,/lever-status(and/lever-status <id> cancel [<reason>]for retirement). Use the Workflow bullets fromtemplates/AGENTS.md. If the file already has a## Workflowheading, append at its end (before the next##or EOF); otherwise add a new## Workflowsection. Surface in chat:"Appended a Workflow section to AGENTS.md — review and revert if you'd rather wire the skills differently."
Detect the lever-mention case with:
grep -qE '/lever-new|/lever\b|/lever-status' AGENTS.md
The append is safe (additive, narrative-only) — no risk of overwriting prose. Init never edits any other AGENTS.md content.
4. Wire host context files (write missing, verify existing)
For each of CLAUDE.md and GEMINI.md:
Missing. Write the import shim. The
[ -f … ] ||guard is POSIX bash:[ -f CLAUDE.md ] || printf '@AGENTS.md\n' > CLAUDE.md [ -f GEMINI.md ] || printf '@AGENTS.md\n' > GEMINI.mdExists. Grep for
@AGENTS.md. If absent, the host file won't pick upAGENTS.md— silent break. List each broken file with the suggested one-line edit under aDrift detected:heading and stop. Init never edits existing host files.
Copilot needs no shim — it reads AGENTS.md natively.
5. Surface the gitignore choice
Lever artifacts (.agents/levers/<id>-<slug>/) are committed by default — useful audit trail. If the user prefers to ignore them (PII, scratch), they add .agents/levers/ to .gitignore themselves. Surface as one line under Gitignore choice: in the chat reply; don't write it for them.
6. Hand off
Invariant: .agents/levers/ exists and isn't gitignored; AGENTS.md exists (written, appended-to, or pre-existing) and references the lever skills; host shims actually import AGENTS.md. End the chat reply with one clear sentence stating what just happened and the next command.
- Ready — everything in place. Recommend
/lever-new <short-title-of-first-task>. - Ready, AGENTS.md just written/appended — same recommendation, plus a note to fill in placeholders or review the appended section.
- Blocked — not a git repo;
.agents/levers/is gitignored; or a host file exists without importingAGENTS.md. Name the blocker and the fix.