Getting it into your agent
This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.
/plugin marketplace add tzachbon/smart-ralph/plugin install ralph-specumWrote 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/tzachbon/smart-ralph/refactor)<a href="https://agentmods.dev/commands/tzachbon/smart-ralph/refactor"><img src="https://agentmods.dev/badge/commands/tzachbon/smart-ralph/refactor/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.
<a href="https://agentmods.dev/commands/tzachbon/smart-ralph/refactor"><img src="https://agentmods.dev/badge/commands/tzachbon/smart-ralph/refactor.svg" alt="Reviewed on agentmods" width="80" 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.00000 | $0.01657 |
| Opus 5.5 | $0.00000 | $0.00663 |
| Sonnet 5.5 | $0.00000 | $0.00331 |
| Haiku 4.5 | $0.00000 | $0.00166 |
Grade A, and why
refactor 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 1mo 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.
How it starts
The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactor Spec
Update specification files after execution. You are a coordinator, not a writer -- delegate actual updates to the refactor-specialist subagent.
Checklist
Create a task for each item and complete in order:
- Gather context -- resolve spec, read existing files and learnings
- Determine scope -- which files to refactor (from --file flag or all)
- File-by-file review -- section-by-section review with user for each file
- Delegate updates -- dispatch refactor-specialist for each file
- Handle cascades -- propagate changes downstream if needed
- Finalize -- update state, commit
Step 1: Gather Context
- If
$ARGUMENTScontains a spec name, useralph_find_spec()to resolve it; otherwise useralph_resolve_current() - If no active spec, error: "No active spec. Run /ralph-specum:new first."
- Check the resolved spec directory exists
- Read
.ralph-state.jsonif exists - Identify which spec files exist:
requirements.md,design.md,tasks.md - If no spec files exist, error: "No spec files found. Run /ralph-specum:start first."
- Read
.progress.mdto understand implementation learnings
Step 2: Determine Scope & Present Overview
Check $ARGUMENTS for --file= flag:
--file=requirements: Only requirements.md--file=design: Only design.md--file=tasks: Only tasks.md- No flag: All files in order (requirements -> design -> tasks)
Present overview to user:
Spec: $spec
Files to review:
- requirements.md: [exists/missing] - [brief summary: X user stories, Y requirements]
- design.md: [exists/missing] - [brief summary: X components, Y decisions]
- tasks.md: [exists/missing] - [brief summary: X tasks, Y completed]
Implementation learnings from .progress.md:
- [Key learning 1]
- [Key learning 2]
Prototype Refactor Gate
After resolving the ordered file list above and before any refactor dispatch:
- Whenever
.ralph-state.jsonexists, reconcile candidates and finals once, even whenactivePrototypesis absent or empty:python3 "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/prototype-records.py" reconcile --base-path "$SPEC_PATH" --state "$SPEC_PATH/.ralph-state.json" - For each resolved file in scope, run selection with that exact file as both target and path:
python3 "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/prototype-records.py" select-downstream --base-path "$SPEC_PATH" --state "$SPEC_PATH/.ralph-state.json" --target "$FILE" --path "$FILE" - Stop that file's refactor dispatch when
activeBlockerstargets the file or transition, when its task index appears instaleTaskIndexes, or whenstaleArtifactscontains the file or an upstream dependency. - Preserve a file only when its matching
targetDecisionsentry hasproofAvailable: trueandeligible: true. Missing dependency or approved-transfer proof blocks that file conservatively. - When refactor resumes execution, restore
taskIndexfrom the relevant entry'sreturnTaskIndexbefore task dispatch.
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.
- 1mo ago First seen · 169 lines · 0 tokens per session scan A d6a785f75472
refactor is a command published in the GitHub repository tzachbon/smart-ralph (559 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,657 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-09-03.
Other commands, from other repositories
resume-project
Run resume-project now — Now / Blocked / Next. Not a cheat sheet.
backlog
PitWay: Capture out-of-scope work discovered mid-task, without expanding current scope.
frankx-ai-build
Comprehensive FrankX.AI website build session - plan, create, review, deploy.
publish
Publish a reviewed content packet through the canonical publisher and verify the remote result.
acos-swarm
Initialize a coordinated swarm of agents for complex, multi-file tasks.
plan-update
Update an initiative's status, progress, tasks, or add agent commentary.