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/marcoemrich/agentic_coding_lab/refactorgit clone --depth 1 https://github.com/marcoemrich/agentic_coding_labWhat 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 | $0.00000 | $0.01471 |
| Opus 5 | $0.00000 | $0.00736 |
| Sonnet 5 | $0.00000 | $0.00294 |
| Haiku 4.5 | $0.00000 | $0.00147 |
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 2d 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 — 212 lines — stays where its author put it; the contents beside it link to each section on GitHub.
TDD Refactor Phase
You are now in the Refactor Phase of TDD. Follow these instructions to improve the code while keeping tests green.
Your Mission
- MUST attempt at least one refactoring - mandatory, not optional
- Apply Kent Beck's Four Rules of Simple Design (priority order)
- Use Absolute Priority Premise (APP) to measure improvements
- Keep all tests green throughout
- Document decisions and mass calculations
- If no improvement possible, explicitly document why
Context: $ARGUMENTS
Refactor Phase Rules
- Mandatory refactoring attempt: MUST try at least one improvement
- Tests must stay green: Never break passing tests
- Apply Simple Design Rules: In priority order (1 → 2 → 3 → 4)
- Calculate APP mass: Before and after refactoring
- Document decisions: Explain improvements or why none were possible
- Naming is first priority: Evaluate if function name still fits
Simple Design Rules (Priority Order)
Rule 1: Tests Pass (Highest Priority)
- All tests must pass before and after refactoring
- If tests fail, revert and try different approach
Rule 2: Reveals Intent
- Use meaningful names for variables, functions, classes
- Structure code to be self-documenting
- Prefer explicit over clever code
- Naming Evaluation (FIRST):
- Does this name clearly describe what the function does?
- Has the function's purpose become clearer through the latest test?
- Rename if the name doesn't capture the current full intent
Rule 3: No Duplication (DRY)
- Extract common functionality
- Look for obvious and conceptual duplication
- Balance with Rule 2: If DRY hurts clarity, choose clarity
Rule 4: Fewest Elements (Lowest Priority)
- Remove unnecessary abstractions
- Keep it simple - don't over-engineer
- Only add complexity when it serves clear purpose
Absolute Priority Premise (APP)
Mass Calculation
Total Mass = (constants × 1) + (bindings × 1) + (invocations × 2) +
(conditionals × 4) + (loops × 5) + (assignments × 6)
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.
- 2d ago First seen · 212 lines · 0 tokens per session scan A 274d49a55cbb
refactor is a command published in the GitHub repository marcoemrich/agentic_coding_lab (11 stars, last pushed 15d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,471 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-30.
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.
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.
implement
Execute the implementation plan by processing and executing all tasks defined in tasks.md.