hermit-agent: Command for Claude Code

.claude/commands/code-polish-hermit.md

code-polish-hermit is a command for Claude Code from cafitac/hermit-agent. It costs 0 tokens per session (1,539 once invoked), scanned A, original, MIT.

A command that repeatedly reviews and fixes a GitHub pull request until it is clean, then adds two independent review passes as a final check.

In plain words
What is it for?
Use it to polish a pull request with an aggressive, moderate, or conservative review strategy, provided the required review service and project tests are available.
Why use it?
It reduces the manual work of finding issues, applying fixes, and reviewing the same pull request again. A pull request is a proposed set of code changes awaiting review.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: reads .claude/ paths; mentions subagents.

This is cafitac/hermit-agent's own configuration. It tells Claude Code how to work on hermit-agent itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything hermit-agent configures →

Reuse

Borrowing it

Nothing to install: this file belongs to cafitac/hermit-agent. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cafitac/hermit-agent/main/.claude/commands/code-polish-hermit.md
Clone the repo
git clone --depth 1 https://github.com/cafitac/hermit-agent

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-polish-hermit

README.md
[![agentmods](https://agentmods.dev/badge/commands/cafitac/hermit-agent/code-polish-hermit/github.svg)](https://agentmods.dev/commands/cafitac/hermit-agent/code-polish-hermit)
Your own site
<a href="https://agentmods.dev/commands/cafitac/hermit-agent/code-polish-hermit"><img src="https://agentmods.dev/badge/commands/cafitac/hermit-agent/code-polish-hermit/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for code-polish-hermit

Your own site · 80×15
<a href="https://agentmods.dev/commands/cafitac/hermit-agent/code-polish-hermit"><img src="https://agentmods.dev/badge/commands/cafitac/hermit-agent/code-polish-hermit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,539 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01539
Opus 5.5 $0.00000 $0.00616
Sonnet 5.5 $0.00000 $0.00308
Haiku 4.5 $0.00000 $0.00154

Measured 2mo ago against content hash 8c56155e157a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

code-polish-hermit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/code-polish-hermit.md · 197 lines

How it starts

The opening of the file, as written. The whole thing — 197 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/code-polish-hermit — state-machine polish loop

Unlike /code-polish, this variant is a distributed state machine. Hermit runs its own review-and-apply loop until it is self-clean, and Claude provides two independent review passes on top as a quality gate. Claude's token spend is capped at ~2 review rounds.

Arguments

$ARGUMENTS — PR number (required).

  • --strategy {aggressive|moderate|conservative} — delegation depth. If omitted, read from the model-strategy map in the checkpoint config (same mechanism as /feature-develop-hermit).

Prerequisites

  • Hermit gateway + MCP server running.
  • Valid PR branch / worktree resolved.
  • Project's test runner works (Hermit will invoke it).

State machine

HERMIT_LOOP          ← Hermit self-reviews and fixes until clean
     ↓
CC_REVIEW_1          ← Claude review pass 1
     │               ↓ findings? ←─────┐
     │                                 │
     └── clean ──→ CC_REVIEW_2         ↑
                        │              │
                        ↓              │
                     clean             │
                        ↓              │
                      DONE             │
                                       │
              findings? ──→ HERMIT_LOOP (iteration+1)

The loop terminates when two Claude review passes back to back are clean, or the global iteration limit (5) is hit, or Hermit fails three times in a row.

Workflow

Step 1 — lock

mkdir -p .hermit
cat > .hermit/active-task.lock <<EOF
{
  "task_id": "<filled-after-run_task>",
  "started_at": "$(date -Iseconds)",
  "skill": "code-polish-hermit",
  "state": "HERMIT_LOOP",
  "iteration": 0,
  "pr": "$ARGUMENTS"
}
EOF

Step 2 — state HERMIT_LOOP (initial entry)

mcp__hermit__run_task(cwd=<worktree>, background=true, model=<--model or "">)

You are Hermit. Polish PR #<PR-number> to your own "first clean" state.

Loop (max 5 internal iterations):
1. Self-review the PR diff against the project's review criteria.
   Output Pn findings.
2. If findings are empty → STOP and report `self_clean: true`.
3. Otherwise, apply every finding.
4. Re-run the review.
5. Repeat.

Rules:
- TDD: every code change updates or adds tests; confirm the test
  runner passes before closing an iteration.
- Preserve existing behaviour — never silently drop validation,
  error handling, or cleanup.
- Do NOT commit or push.
- Stay in scope: touch only files in this PR's diff (or the
  refactoring targets listed in `.omc/plans/<branch>-patterns.md`
  if it exists).
- Ambiguous fix direction → call ask_user_question.

Completion:
- self_clean: true, OR internal iteration limit reached.
- Return: final state, iterations used, files modified.

Read the full file on GitHub · 197 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 197 lines · 0 tokens per session scan A 8c56155e157a

Subscribe to this mod's changes

code-polish-hermit is a command published in the GitHub repository cafitac/hermit-agent (4 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,539 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.