agentleFS
mauroepcemauroepce/claude-workspace/skills/safe-commit/SKILL.md

safe-commit

Skill1 starsChanged 3 months agoMITView on GitHub

Run a security review on staged changes, generate a commit message tied to the original spec from /work, and commit only after explicit user confirmation. Never bypasses hooks.

  • Reads credentials

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. 0 are common, 8 are distinctive, and 10 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If nothing is staged, tell the user: "No staged changes.

    line 18
  2. Distinctive:

    If there are staged changes, present:

    line 20
  3. Very specific:

    If must-fix findings exist: stop and tell the user "There are must-fix findings.

    line 38
  4. Distinctive:

    If should-fix only: ask "Want to address these now or note them for follow-up?"

    line 39
  5. Distinctive:

    If nice-to-have or clean: proceed to Phase 3.

    line 40
  6. Very specific:

    If /security-review isn't available or fails, fall back to manually scanning for:

    line 46
  7. Distinctive:

    Check for a persisted spec:

    line 71
  8. Very specific:

    If specs exist, read the newest one with Status: in-progress.

    line 77
  9. Very specific:

    If the diff includes changes outside the spec's scope, suggest splitting the commit (git reset and re-stage) so each commit maps to one …

    line 81
  10. Very specific:

    If no spec file exists but the user followed /work in this same session, fall back to asking: "Briefly — does this commit deliver the spec …

    line 83
  11. Very specific:

    If they didn't use /work at all, skip this phase.

    line 85
  12. Distinctive:

    If they revise, regenerate.

    line 110
  13. Very specific:

    Never use --no-verify: If a hook fails, surface the failure and ask the user how to handle it.

    line 116
  14. Very specific:

    Don't add Co-Authored-By: Claude unless the repo opts in via its own CLAUDE.md or the conventions file's GIT ETIQUETTE section records a …

    line 133
  15. Very specific:

    Don't bypass git hooks with --no-verify for any reason.

    line 134
  16. Distinctive:

    Don't commit if blockers exist.

    line 135
  17. Distinctive:

    Don't generate a generic message ("update files", "minor changes").

    line 136
  18. Distinctive:

    Don't auto-amend. If the user wants to amend, they ask explicitly.

    line 137

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/safe-commit — Reviewed commit

You are Claude. The user is about to commit staged changes. Your job is to make this commit safe and intentional, not autopilot.

Phase 1 — Inspect what's staged

Run:

git status --short
git diff --cached --stat

If nothing is staged, tell the user: "No staged changes. Run git add <files> first, then /safe-commit again." Stop.

If there are staged changes, present:

STAGED CHANGES
Files: <count>
Lines: +<added> / -<removed>

<list of files with their diff stat>

Phase 2 — Code review (quality and correctness)

Invoke /code-review against the staged changes. This is the quality pass: naming, complexity, pattern adherence, test coverage, edge cases, error handling, performance traps.

Present the standard /code-review output (must-fix / should-fix / nice-to-have / strengths).

Decision tree:

  • If must-fix findings exist: stop and tell the user "There are must-fix findings. Address them, re-stage, and run /safe-commit again. I'm not going to commit code that wouldn't pass PR review."
  • If should-fix only: ask "Want to address these now or note them for follow-up?"
  • If nice-to-have or clean: proceed to Phase 3.

Phase 3 — Security review

Invoke /security-review against the staged diff (built-in Claude Code skill). This is a separate concern from quality — it looks specifically for threat patterns: hardcoded secrets, injection, auth/permission changes, unverified inputs, leaked PII, etc.

If /security-review isn't available or fails, fall back to manually scanning for:

  • Hardcoded secrets (API keys, tokens, passwords) — match patterns like sk-, Bearer , AKIA, xoxb-, ghp_, password = "..."
  • New env vars referenced without being added to .env.example
  • Suspicious changes to authentication, authorization, or permissions code
  • New external HTTP calls without timeouts or error handling
  • SQL queries built with string concatenation (potential injection)
  • Disabled tests or skipped assertions
  • .env, .pem, id_rsa, or any other obvious secret file accidentally added

Present findings in this format:

SECURITY REVIEW
✓ <N> checks passed
⚠ <N> warnings:
  - <warning 1 with file:line>
✗ <N> blockers (if any):
  - <blocker 1 with file:line>

Same decision tree as Phase 2: blockers stop the commit, warnings prompt the user.

Phase 4 — Verify spec alignment (if /work was used)

Check for a persisted spec:

ls -t .claude/specs/*.md 2>/dev/null | head -3

If specs exist, read the newest one with Status: in-progress. Compare the staged diff against its "Changes / does NOT change" and "Success criteria" sections, then tell the user:

"Spec check against .claude/specs/<file>: <delivers the spec / partially — X is missing / includes out-of-scope changes: Y>"

If the diff includes changes outside the spec's scope, suggest splitting the commit (git reset and re-stage) so each commit maps to one spec. After a commit that completes the spec, update its Status: to done.

If no spec file exists but the user followed /work in this same session, fall back to asking: "Briefly — does this commit deliver the spec from /work Phase 1?"

If they didn't use /work at all, skip this phase. Don't lecture them.

Phase 5 — Commit message

Generate a commit message that follows this structure:

<type>: <subject in imperative mood, max 72 chars>

<2-4 sentence body explaining the WHY, not just the what>
<reference issue if applicable: "Refs #47" or "Closes #47">

Types: feat, fix, refactor, chore, docs, test, perf, style.

The body should answer: why was this change necessary? Not "I changed X to Y" but "X was failing under condition Z because of constraint W; Y handles it correctly."

Trailer resolution (Co-Authored-By: Claude) — decide before showing the message, in this order:

  1. The repo's own CLAUDE.md states a rule (opt-in or prohibition) — it wins.
  2. The conventions file (.claude/conventions.md or its .local variant) has a GIT ETIQUETTE section — recorded by /onboard's first-run question — honor it.
  3. Neither exists — no trailer (the default).

Show the user the message and ask: "Commit with this message?"

If they revise, regenerate. If they approve, run:

git commit -m "<subject>" -m "<body>"

Never use --no-verify. If a hook fails, surface the failure and ask the user how to handle it. Don't bypass hooks.

If the commit is blocked by the framework's commit gate (message mentions COMMIT GATE / .claude/review-passed): the staged diff no longer matches the last review — something was staged after Phase 2. Do NOT use the SKIP_REVIEW_GATE override; re-run /code-review so the receipt covers exactly what is being committed, then retry.

Phase 6 — Confirmation

After commit succeeds:

git log --oneline -1
git status

Confirm the commit landed, working tree state is what the user expected. Don't push — that's /safe-push.

What NOT to do

  • Don't add Co-Authored-By: Claude unless the repo opts in via its own CLAUDE.md or the conventions file's GIT ETIQUETTE section records a yes.
  • Don't bypass git hooks with --no-verify for any reason.
  • Don't commit if blockers exist.
  • Don't generate a generic message ("update files", "minor changes"). If you can't articulate the why, ask the user.
  • Don't auto-amend. If the user wants to amend, they ask explicitly.
  • Don't push.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.