Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add commands/orlando-japan/claude-code-setting/refactor-surgicalgit clone --depth 1 https://github.com/orlando-japan/claude-code-settingWrote 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.
[](https://agentmods.dev/commands/orlando-japan/claude-code-setting/refactor-surgical)<a href="https://agentmods.dev/commands/orlando-japan/claude-code-setting/refactor-surgical"><img src="https://agentmods.dev/badge/commands/orlando-japan/claude-code-setting/refactor-surgical.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00014 | $0.00381 |
| Opus 5 | $0.00007 | $0.00191 |
| Sonnet 5 | $0.00003 | $0.00076 |
| Haiku 4.5 | $0.00001 | $0.00038 |
Grade A, and why
refactor-surgical 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 5d 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.
What it actually says
Refactor: $ARGUMENTS
The contract: behavior before == behavior after. Only internal structure changes.
Protocol:
- Run the existing tests first. Green baseline. If they're not green, stop and fix them first — a refactor on red is a rewrite.
- List the refactor in ≤5 bullets before touching code: what's moving, what's renaming, what's extracting. If the list grows beyond 5, you're doing too much — split it.
- One step at a time. Make one refactor, run tests, commit. Make the next, run tests, commit. Don't batch.
- Don't change public interfaces. If you must, it's not a refactor — it's a migration, and it needs a spec.
- Don't rename things "while you're in there." Renames are cheap with tooling and expensive with ad-hoc edits. If they're worth doing, they're worth doing in their own commit.
- Don't introduce new abstractions. The purpose is to clean up what exists, not to speculate about the future.
Stop conditions:
- Tests go red → stop, revert, diagnose.
- Scope creep detected → stop, surface to user, ask.
- You discover the original code was wrong (not just ugly) → stop, surface the bug, don't silently fix it in the refactor.
Done looks like: same tests green, diff is smaller and clearer than before, no new public API.
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.
- 5d ago First seen · 27 lines · 14 tokens per session scan A a8d1420186c0
refactor-surgical is a command published in the GitHub repository orlando-japan/claude-code-setting (2 stars, last pushed 3mo ago), licensed MIT. It adds 14 tokens to every session and 381 once invoked, about $0.0001 per session on Opus 5. 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.
Other commands, from other repositories
checklist
Generate a custom checklist for the current feature based on user requirements.
clarify
Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec.
specify
Create or update the feature specification from a natural language feature description.
analyze
Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation.
constitution
Create or update the project constitution from interactive or provided principle inputs.
converge
Assess the current codebase against the feature's spec, plan, and tasks, then append any remaining unbuilt work as new tasks to tasks.md so implement can complete it.