/continuous-improvement:reconcile runs instead · from continuous-improvement
Reads git state (branch, upstream, ahead/behind, drift, stashes, worktrees, in-progress ops) before staging, committing, pushing, and opening a PR. Use when multiple sessions touch the same checkout or before landing finished work.
This skill never runs in Claude Code
It ships in continuous-improvement at skills/, but /continuous-improvement:reconcile (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
Law 1 says research before executing. The most expensive skipped research is the state of your own repo: a branch that shifted under you, a push that silently did not land, a stash from a session you forgot. This skill establishes git ground truth first, acts only on a known state, stops at every operation that is hard to reverse, and then carries that known-good state all the way through a single-concern commit, a push, and an open PR — ending back on an up-to-date default branch once the PR merges.
.plans/<branch>/ if the branch carries them (/planning-with-files recover).Read before you write. One command runs the whole pass and prints the resolved-state block. Claude Code replaces ${CLAUDE_PLUGIN_ROOT} with the plugin's install path when it loads this file. On an npm install, where nothing replaces it, run npx -p continuous-improvement ci-reconcile with the same flags.
node "${CLAUDE_PLUGIN_ROOT}/bin/reconcile.mjs" # resolved-state block; exit 1 if anything blocks a mutation
node "${CLAUDE_PLUGIN_ROOT}/bin/reconcile.mjs" --json # the same state, machine-readable
node "${CLAUDE_PLUGIN_ROOT}/bin/reconcile.mjs" --explain # print the probe set and why each probe runs
Exit codes: 0 nothing blocks, 1 at least one blocker, 2 not a git repository. The probe set is defined once in src/lib/git-state.mts, and npm run verify:reconcile-parity fails if this document drifts from it — the list below is the list the runner executes.
Run the pass by hand when the runner is not installed:
git rev-parse --show-toplevel # inside a work tree, and where
git rev-parse HEAD # the sha every later claim is relative to
git symbolic-ref --quiet --short HEAD # branch name; NON-ZERO EXIT = detached HEAD
git rev-parse --abbrev-ref --symbolic-full-name @{u} # upstream, or non-zero = none configured
git rev-list --left-right --count @{u}...HEAD # behind/ahead — only after the line above succeeded
git status --porcelain=v1 # reported changes (inflated by autocrlf)
git diff --name-only --ignore-all-space # real content drift — the number to trust
git stash list
git worktree list --porcelain
git rev-parse --git-path MERGE_HEAD # in-progress op: test the RESOLVED path for existence
Four boundaries make the obvious commands lie. Each was reproduced against real git; do not simplify them back.
git rev-list for counts against @{u} exits 128 with fatal: no upstream configured — it does not return zeros. Probe for the upstream first and ask for counts only once it resolved. With no upstream, compare against origin/<default> explicitly; never read the failure as "even".--show-current form of git branch prints an empty string and exits 0, so a detached HEAD is indistinguishable from a successful read. git symbolic-ref --quiet --short HEAD exits non-zero instead, which is checkable. A detached HEAD blocks: there is no branch to commit onto, push, or name in a PR..git is a file, not a directory, so listing a .git/-relative path for MERGE_HEAD fails with "Not a directory" and exit 2 — byte-identical to the "no operation in progress" result on a clean tree. A real conflicted merge therefore reads as clean. Resolve the marker with git rev-parse --git-path MERGE_HEAD and test that path; it is correct in a main checkout and in a worktree alike. Same for rebase-merge, rebase-apply, CHERRY_PICK_HEAD, REVERT_HEAD, BISECT_LOG.autocrlf=true. git status reports phantom line-ending-only modifications. Trust git diff --stat / git diff --name-only --ignore-all-space for real content drift. Never stage with git add -A / git add . on such a tree — stage by explicit filename. The runner prints both numbers so the gap is visible instead of assumed.The ground-truth pass has to work wherever the agent runs, not only in Bash. ci-reconcile spawns git argv directly with no shell, so it needs no bash, no coreutils, and no .git/-relative path.
| Surface | PowerShell / cmd | Git Bash / WSL | POSIX shell | Linked worktree | Detached HEAD | No upstream |
|---|---|---|---|---|---|---|
ci-reconcile (Node) | yes | yes | yes | correct | blocks | warns |
scripts/git-state-snapshot.sh | needs Git Bash | yes | yes | root/branch only | reports detached | reports none |
| Hand-run probe list above | yes | yes | yes | correct | non-zero exit | non-zero exit |
Smoke-test on the OS you actually ship on. Both surfaces emit the same {head, upstream, dirty, root, branch} envelope — ci-reconcile --snapshot adds contentDrift, inProgress, blocked and blockers — and a test pins that parity so the two cannot drift apart silently.
--snapshot follows the same exit-code contract as the default mode: 0 clear, 1 at least one blocker, 2 not a git repository. It still writes the envelope on a blocker, so a script that wants the JSON regardless must tolerate exit 1 (set -e will otherwise abort on a detached HEAD or an unborn repo).
An unborn HEAD — git init with no commit yet — is a real git repository with no usable baseline. git rev-parse HEAD fails there, so the shell script reports not-a-git-repo and the envelope's head field would otherwise be empty in a way that reads like success. ci-reconcile reports head: "unborn" with blocked: true and blocks the mutation instead.
When another session/loop may be active, do not assume the tree is yours:
MERGE_HEAD / rebase-merge you did not start means another actor is mid-operation. Do not "help" by editing conflicted files — wait, or hand off. The runner reports this as a blocker; the retired .git/-relative probe could not see it inside a worktree at all.node "${CLAUDE_PLUGIN_ROOT}/bin/reconcile.mjs" --snapshot > .git/reconcile-baseline.json # or any scratch path
# ... do work ...
node "${CLAUDE_PLUGIN_ROOT}/bin/reconcile.mjs" --snapshot # compare head + branch against the baseline
If either field moved, another writer got there first — re-survey from the top instead of committing onto an unexpected base. A missing or unparseable field counts as shifted; "we could not tell" is never "nothing moved". Both calls exit 1 if the tree is blocked, so capture the baseline without set -e (or guard it) when a blocker is expected.git worktree list --porcelain means a sibling checkout exists that another session may be writing to. The runner flags this. Read this checkout's own entry in that list too: a prunable line, or a locked line whose reason names another session (owner=<session-id>, the form /ship writes), means stop and do not write here. When the worktree you meant to work in is missing or fails either check, never fall back to the primary checkout: stop and report it.hooks/gateguard.mjs reads no git state: it captures no baseline and does not notice another session writing to the same checkout. Capture and compare the baseline yourself, with ci-reconcile --snapshot as above or with bash "${CLAUDE_PLUGIN_ROOT}/scripts/git-state-snapshot.sh" (source: scripts/git-state-snapshot.sh). The shell snapshot needs Git Bash and derives its dirty count from git status, which overstates drift on an autocrlf tree. ci-reconcile --snapshot is the same envelope without either limitation.Map the upstream relationship before choosing an action:
git pull --ff-only.--force.Branch from a base only after confirming local <base> equals origin/<base> — a squash-merge will otherwise silently bundle ahead-of-origin commits.
STOP and get explicit authorization before:
main). Use a feature branch and a PR, not a direct push.git branch -D) — both stay human decisions, never auto-actions on green CI.git push --force / --force-with-lease, git reset --hard, git clean -fd, worktree remove on a dirty worktree, or dropping a stash with uncommitted value.If a rebase has diverged and force-push is gated, do not force-recover — supersede via a new branch + new PR.
Once ground truth is known and the halt gates are clear, carry the work to an open PR without leaving the known-good state. This tail is self-contained — it reimplements the commit → push → PR steps with plain git/gh and depends on no companion plugin.
Cut or confirm a feature branch from a fresh base. Never commit onto a protected branch. Sync the default branch first so the feature branch is not born stale:
git switch main && git pull --ff-only origin main # master on older repos
git switch -c <type>/<slug> # only if not already on a feature branch
Confirm local main equals origin/main before branching — a squash-merge otherwise bundles ahead-of-origin commits.
Stage by explicit filename. One concern per commit. On an autocrlf tree git add -A / git add . commits phantom line-ending-only changes — name each path and read real drift with git diff --stat.
git add path/one path/two
Commit with a Windows-safe message. Lead with the observable outcome. Use a single-line -m (repeat -m for paragraphs) or git commit -F <tempfile> — never a multi-line here-doc/here-string, which CRLF and shell quoting corrupt on Windows.
git commit -m "feat(scope): <observable outcome>"
Push the feature branch (never the protected branch), then verify it landed via the section below:
git push -u origin <type>/<slug>
Open one PR citing the plan or issue, then stop:
gh pr create --fill --base main
Stop here. The merge is a human decision. reconcile never merges the PR, never uses --admin / --force / --no-verify, never auto-merges on green CI, and never deploys.
A push that printed no error is still a claim. Confirm:
node "${CLAUDE_PLUGIN_ROOT}/bin/reconcile.mjs" --verify-push <branch> # exit 0 only when the remote tip equals local HEAD
or by hand:
git rev-parse HEAD
git ls-remote origin refs/heads/<branch> # remote tip must equal local HEAD
There are three outcomes here, not two, and collapsing them is how a false report gets made:
git ls-remote itself failed (network, auth, remote down). This is not evidence the push failed; it is evidence you do not know. Retry the probe. Never report success, and never report failure, from a probe that did not run.Report only what the probe proved.
"All the latest work on main" is only true once the PR actually merges — and on a protected branch that merge is a human action, not something reconcile performs. After the merge lands, return to an up-to-date default branch:
git switch main # or master on older repos
git pull --ff-only origin main # fast-forward only; never a merge commit or --force
git rev-parse HEAD # confirm this equals the squash-merge SHA from the PR
git branch -d <type>/<slug> # delete the merged feature branch (safe -d, never -D)
--ff-only is deliberate: if the pull would not fast-forward, main diverged under you — stop and re-survey from Establish Ground Truth First instead of forcing it. You end on the default branch with every merged change present and the feature branch cleaned up.
recall (Law 1) — before a risky git op, recall whether the same operation failed on this repo before.gateguard (Law 1): hooks/gateguard.mjs refuses destructive git commands such as git reset --hard, git clean -f, a force push and git branch -D, and it reads no git state. reconcile is how you find out what such a command would change before you show it to the user.audit (Law 4): audit reports only, unless the user asks for fixes. When it does end in a fix, reconcile is the safe path from branch to landed PR.commit-commands:commit-push-pr: the external-plugin equivalent of the commit → push → PR tail. reconcile reimplements it inline so the flow works with no companion installed. To take one fix to a PR with quoted test evidence, the user runs /ship.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub naimkatiman/continuous-improvement --plugin continuous-improvement22 skills in this plugin
/auditReview a code change and report only bugs proven against the code: pin the diff, read every changed file and log it in a coverage ledger, run one find pass per defect class, then confirm each finding at the cited lines. Use when asked to review a branch or pull request (PR) for broken code before it merges, or to audit commits that already merged. Reports only, unless the user asks for fixes. Not for checking your own work in progress, style or design feedback, or debugging a known failure. Guidance for Law 4 (Verify Before Reporting)./be-ambitiousTakes one task and works it at three kinds of ambition (Altitude, the goal behind the task; Depth, the way a top expert in the field would do it; Range, other fields doing their real work), fixes a numeric target and an outside judge before the work starts, then does the work. Use when the user says go big or a plan looks timid. It still has the agent deliver the literal ask and wait for a yes on anything hard to reverse. Method from Felix Rieseberg's "How to be more ambitious", restated. Guidance for Law 2 (Plan Is Sacred)./continuous-improvementThe drive pillar, beside the be-ambitious skill (ambition). Tells the agent to work a task in seven steps: research, plan, implement, review, contemplate, relearn and learn, iterate. Use when a task changes code (fix, refactor) or runs commands. Also use for a first recommendation or when someone asks which available skill fits their task. Before the final report, if the user corrected you, an approach was dropped or a check failed twice, or when the user asks to reflect: read the session log, write the reflection and save its rule as a project instinct the next session can load. Other simple questions can be answered directly./deploy-receiptHas the agent prove a merge reached production: read the deployed commit SHA from the provider CLI, the GitHub Deployments API or a version endpoint, compare it with the merge SHA, check that a healthcheck returns 200, and print a COMPLETE or INCOMPLETE receipt. Use when a merge has just landed on a branch that deploys automatically (Railway, Cloudflare Workers, Vercel, Netlify, Fly.io). Not for libraries published as packages, manual deploys or branches that do not deploy. It never deploys, merges or rolls back. Guidance for Law 4 (Verify Before Reporting)./gateguardDescribes hooks/gateguard.mjs, the hook that refuses destructive shell commands and blind edits (an edit of an existing file the session has not read), and tells the agent to stop, show the user the command and wait after a refusal. Use when about to run a command that deletes or overwrites data (rm -rf, git reset --hard, git clean, a force push, DROP TABLE, Remove-Item -Recurse), when a call comes back refused, or before editing a file not yet read. Not for getting a refused command to run (only the user can) and not a sandbox. Guidance for Law 1 (Research Before Executing)./goal-monitorScores recent tool activity against the Goal section of task_plan.md and reports ON GOAL, DRIFT or NO DATA, so the agent steers back or updates the goal on purpose. Use when a long stretch of work or edits may have strayed from the plan, and before a checkpoint or handoff. Not for a session with no written goal. Run it with the ci_goal_check tool or /goal-check. A hook, hooks/goal-drift-stop.mjs, runs the same check when a turn ends: it warns by default and re-prompts the agent only when CLAUDE_GOAL_DRIFT_GATE=block. Guidance for Law 2 (Plan Is Sacred).Other plugins' skills for the same job