Mmcp.market

commit skill

by pedrohcgs·pedrohcgs/claude-code-my-workflow·1.6k stars·MIT

Commit the current work — runs the quality, consistency and passport gates, branches off main if needed, stages specific files, and writes a commit whose subject states what is now true. Pushes and opens a pull request only with --pr or when the user asks; never merges — a merge happens only when the user explicitly says to merge. Use ONLY on explicit commit intent — user says "commit", "let's commit this", "open a PR", or prefixes with `/commit`. Do NOT auto-invoke on vague end-of-task phrases ("we're done", "wrap up") — those require explicit confirmation first. Never force-pushes or skips hooks.

A100/100content scan

Is the commit skill safe?

Clean: nothing in its files matched our rules. We read 1 file in the folder on 2026-09-28.

No findings.

Install the commit skill

A skill is a folder. Copy it into your agent's skills folder and the agent loads it when the task matches its description.

git clone --depth 1 https://github.com/pedrohcgs/claude-code-my-workflow.git /tmp/claude-code-my-workflow
mkdir -p ~/.claude/skills
cp -r /tmp/claude-code-my-workflow/.claude/skills/commit ~/.claude/skills/commit
available in every project

In the Claude apps, zip the folder and upload it from the Skills settings. The folder on GitHub

The instructions your agent would load

SKILL.md as published, without the frontmatter. Read it on GitHub

Commit

Verify the gates, then commit. A commit is not a pull request, and a pull request is not a merge. This skill stops after the commit. It pushes and opens a pull request only with --pr or when the user asks, and it never merges — a merge happens only when the user explicitly says to merge that pull request (see "Merging" below). Reviewers such as Codex and Copilot comment after a pull request opens; merging before they report skips their review.

Steps

Step 0: Quality Gate (Pre-Commit)

Run before branching. For every changed .qmd, .tex, or .R file that has quality rubrics, run:

python3 scripts/quality_score.py <changed-file-paths>
  • If any file scores below 80, halt and report the findings. The user must either fix the issues or explicitly override with phrases like "commit anyway" or "skip quality gate". Once ./scripts/install-hooks.sh has been run, .githooks/pre-commit re-runs the same ≥80 gate on the staged .qmd/.tex/.R files, so carry an approved override into Step 4 as SKIPQUALITYGATE=1 git commit ... and record the override reason in the commit message. That variable skips only the quality score; the backtest still runs. Never fall back to git commit --no-verify.
  • If all files score 80+, continue.

Spawn the verifier agent (via the Agent tool with subagent_type=verifier) to run compilation/render checks on the changed files. Report pass/fail before committing.

Step 0b: Consistency Gate (Pre-Commit)

Runs unconditionally. The full backtest suite — all ten gates (surface-sync count claims like "18 agents, 61 skills, 37 rules, 11 hooks" and marked tables, skill integrity, model currency, links, spec conformance, staleness, repo hygiene, derived counts, ledger coverage, hook battery):

./scripts/backtest.sh
  • Exit 0: all gates green — continue.
  • Nonzero: at least one gate is red — print its output and halt. Fix, then re-run. Do not proceed past this gate on a red result, even with "commit anyway": a red gate is drift that the next reader inherits, and small count drift has repeatedly cost follow-up PRs.

Step 0c: Passport Check (Pre-Commit)

If the diff touches a manuscript (.tex/.qmd) that has a passport in qualityreports/passports/, any sourcefile a passport lists, or any file a claim declares as a display (its location:, or an appearsin path:), read that passport: a load-bearing claim with status: FAIL or STALE is a must-fix** — halt, name the claim, and point at /audit-reproducibility (or the stale script) before committing. A touched display triggers the check for the same reason a touched script does: editing one artifact's copy of a number desynchronizes it from that number's other displays — the supplement or deck holding the same value was not necessarily updated in the same commit. Skip silently when no passport exists.

Step 1: Check current state

git status
git diff --stat
git log --oneline -5

Step 2: Create a branch (when on main)

Never commit directly to main. If the current branch is main, create one; if you are already on a feature branch, commit there.

git checkout -b <short-descriptive-branch-name>

Step 3: Stage files

Add specific files (never use git add -A):

git add <file1> <file2> ...

Do NOT stage .claude/settings.local.json or any files containing secrets.

Step 4: Commit with a descriptive message

If $ARGUMENTS is provided, use it as the commit message. Otherwise, analyze the staged changes and write a message that explains why, not just what.

The subject line states what is TRUE AFTER the commit — a plain sentence about behavior that a reader could go and test. "Fixed review feedback" and "Updated the checker" narrate your afternoon and tell a reader nothing; "The parity gate refuses a fixture whose hash is unregistered" is a claim they can check against the code. Process narration — which review round it came from, who asked, how many attempts it took — belongs in the body if it belongs anywhere. The body still carries the why; the subject carries the claim.

git commit -m "$(cat <<'EOF'
<commit message here>
EOF
)"

Step 5: Push and open a pull request — only with --pr or when the user asks

Without --pr, and without the user asking for a pull request, skip this step: the commit stays local and the report says so.

git push -u origin <branch-name>
gh pr create --title "<short title>" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points>

## Changed defaults
<"None", or each default a forker will notice changing: a setting, a threshold, a hook that now fires, a path that moved>

## Test plan
<checklist>

🤖 Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"

Step 6: Report

Report the commit (hash and subject), the branch, and — if a pull request was opened — its URL. Say plainly that nothing was merged.

Merging — only when the user says so

A merge is never a step of this skill. Merge only when the user explicitly asks to merge a specific pull request ("merge #155"); "ship it", "done" or "commit" are not a merge instruction. Before merging, check that the pull request's CI is green and that its reviews (human, Codex, Copilot) have been read and answered.

gh pr merge <pr-number> --merge --delete-branch
git checkout main
git status --porcelain          # must print nothing before the next line runs
git pull

Expect the tree to be dirty here — that is what Step 3 is for. Staging specific files means everything the session touched but did not stage, plus every untracked artifact, is still in the tree when you arrive at this step. The git-guardrails hook this template ships denies git pull (and merge, and rebase) whenever git status --porcelain is non-empty, because a pull that resolves on top of uncommitted work cannot be reviewed afterwards — you can no longer tell which hunk came from the remote. Chaining a stash into the same command line does not help: the hook reads the tree, it does not predict what the line will do to it.

Clear the tree deliberately, then pull:

git stash push -u -m "post-merge: unstaged leftovers"   # -u, or untracked files stay behind
git pull
git stash pop

git pull --autostash is the one-command alternative, but only on a tree whose dirt is entirely tracked. git stash does not stash untracked files, so an autostash over a ?? entry starts the pull on the same dirty tree the check exists to refuse — the hook therefore reads porcelain and denies --autostash whenever any ?? entry is present. At this step that is the usual state, so the explicit -u stash above is the default route and --autostash is the shortcut for the case where git status --porcelain shows no ?? lines at all. Git agrees independently: if the incoming commits add a file at a path you are holding untracked, it aborts the merge ("untracked working tree files would be overwritten") after the autostash has already been taken. Either route must be its own command — chaining the stash and the pull onto one line is denied outright, because an identified history op reaches the tree reading only as a standalone simple command.

ALLOWDIRTYMERGE=1 is the hatch for a dirty state you have looked at and can justify out loud. It is not the routine remedy, and reaching for it because the block is inconvenient is the behavior the check exists to prevent.

Important

  • Never skip Step 0. Quality gates catch broken compilation, bad citations, and hardcoded paths before they reach main. If the user insists on skipping, record their override reason in the commit message.
  • Never commit directly to main; branch off it first.
  • Never push, open a pull request, or merge unless asked — see Step 5 and "Merging".
  • Exclude settings.local.json and sensitive files from staging.
  • When the user does ask to merge, use --merge (not --squash or --rebase) unless they say otherwise.
  • If the commit message from $ARGUMENTS is provided, use it exactly.

Flags

More skills from pedrohcgs/claude-code-my-workflow

  • Aadjudicate-reviewTurn an incoming set of findings — from an AI reviewer, a referee report, a code review, a linter, or a second model — into verified fixes, without letting a confident misread damage correct work. Every finding is a CANDIDATE until checked against the actual source. Use whenever you receive review comments, audit findings, or a critique you did not write yourself, especially when the reviewer is a model or when the volume is too large to check by feel.
  • Aaudit-reproducibilityEnforce the replication-protocol.md rule by cross-checking numeric claims in a manuscript against the actual R / Stata / Python outputs. Report PASS/FAIL per claim against tolerance thresholds. Use before submission and before releasing a replication package.
  • Ablast-radiusBefore and after changing anything shared — a function's return value, a signature, a schema, a label set, a config default, a constant, a file format — find every consumer and actually run them. Catches the change that looks purely additive but silently breaks a contract in a file you never opened. Use when editing shared code, adding a field/column/return element, renaming, changing units or defaults, or touching a pipeline that produces reported numbers.
  • Acapture-environmentSnapshot the computational environment for a replication package — detects the analysis stack (R / Stata / Python) and emits the right lockfiles (renv.lock + sessionInfo.txt, requirements.txt / environment.yml / uv.lock, Stata version + ado package list), records seeds and RNG kind, optionally writes a pinning Dockerfile, and produces a paste-ready "Computational requirements" block. Use when user says "capture the environment", "snapshot my dependencies", "pin the versions", "make a renv.lock / requirements.txt", "make this byte-reproducible", or before releasing a replication package to openICPSR / the AEA Data Editor.
  • AchallengeStress-test a finding against the choices you did not make. Enumerates the discrete forks a competent analyst could have taken (measure definition, sample filter, control set, clustering level, weighting, functional form), runs the specification grid, and reports the distribution rather than a point estimate — then attacks the identifying assumption with named, computable sensitivity statistics. Use when the user says "is this robust", "challenge this result", "specification curve", "multiverse", "how sensitive is this", "what if I'd used a different measure", "stress-test my estimate", or before a result becomes a headline claim. NOT a reviewer of prose or code — it challenges the CLAIM.
  • AcheckpointSave a structured state snapshot before stopping or handing off. Captures the active plan, recent decisions, file pointers (with line numbers), open questions, and the next 1–3 actions into a checkpoint file under `quality_reports/checkpoints/`. Optionally proposes `[LEARN]` entries to add to MEMORY.md. Use when user says "checkpoint", "save state", "snapshot before I stop", "where am I", "wrap up the session for handoff", or before a long break / model switch / collaborator handoff. Companion to (NOT replacement for) the narrative session-log workflow.
  • Acoauthor-briefGenerate a co-author / collaborator handoff brief for a multi-author, multi-machine project — summarizing what changed since the last brief (git delta), the current state of each artifact (manuscript, analysis, slides), open questions, how to reproduce locally, and any restricted-data access steps. Use when user says "coauthor brief", "handoff brief", "bring my coauthor up to speed", "what changed since last week", "onboard a collaborator", "write a handoff for [name]", or before sending a co-author the repo. NOT a commit or a checkpoint — it is the cross-machine, cross-person summary `meta-governance.md` only partially covers.
  • Acompile-latexCompile a Beamer LaTeX slide deck with XeLaTeX (3 passes + bibtex). Use when user says "compile", "build the slides", "rebuild the PDF", "run latex", "render the tex", or asks why a `.tex` file isn't producing a PDF. Operates on `Slides/*.tex`.
  • Acompress-sessionDistill the current conversation into a structured note (decisions made, open questions, file pointers with line numbers, next 1–3 actions) and save to `quality_reports/session_logs/` before auto-compression. Differs from `/checkpoint` (explicit stop-point snapshot) and from auto-compaction (which truncates rather than distills). Use when context is approaching auto-compact threshold, when a long pipeline has accumulated many decisions, or when the user says "compress", "distil this session", "before we hit auto-compact", "structured handoff before context resets".
  • Acontext-statusShow current context status and session health. Use to check how much context has been used, whether auto-compact is approaching, and what state will be preserved.
  • Acreate-lectureCreate a new Beamer lecture `.tex` from source papers and materials, with notation consistency checks and the project's preamble wired in. Use when user says "create a lecture on X", "new lecture from these papers", "start a deck on topic Y", "scaffold a new Beamer file", "build me a lecture from these PDFs". Scaffolds the full deck — NOT for compiling existing `.tex` (use `/compile-latex`).
  • Acredible-claimsResearch-brief + claim-record discipline for delegated or AI-assisted research work. Use when starting any substantive research task or long autonomous run (write the brief first), and when reporting results that will support a claim in a paper or decision (produce the claim record). Keeps faster execution from being confused with credible evidence.

All agent skills → · MCP servers