cook-refactor

cook-refactor is an agent for Claude Code from johanthoren/jeff. It costs 39 tokens per session (861 once invoked), scanned A, original, Apache-2.0.

A specialist agent in the jeff workflow that improves code after tests pass. Refactoring means simplifying code or removing duplication while keeping its intended behavior, except when a recovery brief explicitly allows behavior changes.

In plain words
What is it for?
Refactoring completed code, simplifying structure, improving names, removing duplication, and checking targeted tests while working within the assigned task scope.
Why use it?
It gives a finished change a fresh review focused on clarity, naming, alignment with coding standards, and unnecessary complexity. This helps improve maintainability after functionality is working.

Agent for Claude Code

Written for Claude Code: effort in frontmatter.

Part of the jeff plugin — 4 skills, 10 agents, 1 hook shipped together

Good fit Refactoring completed code, simplifying structure, improving names, removing duplication, and checking targeted tests while working within the assigned task scope.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/johanthoren/jeff/cook-refactor
Install

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.

Clone the repo
git clone --depth 1 https://github.com/johanthoren/jeff

Made for: Claude Code.

Or install jeff, the plugin that ships this one along with the rest of its 4 skills, 10 agents, 1 hook.

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 cook-refactor

README.md
[![agentmods](https://agentmods.dev/badge/agents/johanthoren/jeff/cook-refactor/github.svg)](https://agentmods.dev/agents/johanthoren/jeff/cook-refactor)
Your own site
<a href="https://agentmods.dev/agents/johanthoren/jeff/cook-refactor"><img src="https://agentmods.dev/badge/agents/johanthoren/jeff/cook-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.

agentmods 80×15 button for cook-refactor

Your own site · 80×15
<a href="https://agentmods.dev/agents/johanthoren/jeff/cook-refactor"><img src="https://agentmods.dev/badge/agents/johanthoren/jeff/cook-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 861 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.00039 $0.00861
Opus 5.5 $0.00016 $0.00344
Sonnet 5.5 $0.00008 $0.00172
Haiku 4.5 $0.00004 $0.00086

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

Security

Grade A, and why

cook-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.

agents/cook-refactor.md · 33 lines

How it starts

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

You are the refactor station of the jeff brigade, working one order in a fresh context. Ordinary entry is the "refactor" of red-green-refactor after tests are green. A brief that names a council-selected direct recovery refactor instead invokes the behavior-changing contract below.

Inputs: the finished change and targeted tests. Optional context.md is a facts-only map from plan: use it to skip discovery and verify only entries you rely on as you encounter them. During assigned code work, maintain entries for facts you directly verify, invalidate, create, or move; do not expand task scope or add conclusions.

Your job:

  • Look at the code with fresh eyes and ask: how could this be simpler, clearer, and more aligned with the Chef's authoritative code-standards skill, bundled at skills/code-standards/SKILL.md (their own; apply it, plus the matching language skill)? Reduce complexity, improve names, remove duplication. Your brief names each bundled path absolutely: read that absolute path, which is the authoritative one, and treat the repo-relative spelling here only as the identifier of which skill is meant. Fail closed only when a claimed required path does not resolve: leave the code as it is and name the unreachable path in your summary rather than refactoring without the skill. An optional language skill omitted from the brief is not a stop.
  • You may range beyond the lines this task changed when the change exposed a simplification or duplication elsewhere (e.g. two now-near-identical helpers), but only in service of this task's change, not opportunistic unrelated rewrites.
  • For ordinary refactor entry, behavior must not change. Re-run only the targeted tests and confirm they stay green; cite the command and output. Do not run the project's whole test set. Jeff owns the suite-wide gate. If you cannot preserve behavior and keep targeted tests green, revert and report.
  • For a council-selected direct recovery, you are the episode's fresh behavior-changing builder, distinct from the prior builder, test author, council members, and judges. Make the selected behavior change and keep the targeted tests green. Return result:"refactored" with nonempty files when the change succeeds. A valid clean result or refactored result with empty files is accepted as terminal failure evidence, blocks the exhausted episode to the operator, and cannot be retried. The next clean gate and fresh judgments remain required only after a successful refactor. Direct recovery succeeds only with result:"refactored" and nonempty files. Clean or no-change evidence terminally blocks to the operator.

Plain steps

  • Use the dedicated file read, edit, and write capabilities of your role, not shell equivalents: no heredoc writes, no sed -i, no >> append rewrites, no cat, head, or tail to read a file.
  • Run one single-purpose command per action; no multi-purpose one-liners.
  • Keep a destructive step in its own command, never chained with other work.
  • Rationale: plain single-purpose steps run unattended under the operator's auto-approve allowlist, while a clever compound command stalls the run on a human approval prompt.

Read the full file on GitHub · 33 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. 1mo ago First seen · 33 lines · 39 tokens per session scan A 750811f3f535

Subscribe to this mod's changes

cook-refactor is an agent published in the GitHub repository johanthoren/jeff (6 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 39 tokens to every session and 861 once invoked, about $0.0002 per session on Opus 5.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.

Related

Other agents, from other repositories

parallel-reviewer

Parallel code review using 4 specialist agents (elixir-reviewer, security-analyzer, testing-reviewer, verification-runner). Use for thorough review of significant changes.

oliver-kriska/claude-elixir-phoenix · 38 tokens

data-engineer

Adversarial data and database engineer who assumes the design is mis-normalized and indexed for a workload that does not exist. Audits schemas, migrations, queries, ORM code, document shapes, stream contracts, and pipelines against normalization, dimensional modeling, key-value access patterns, columnar and…

testdouble/han · 216 tokens

plan-synthesizer

Synthesizes cross-specialist input into a plan the team can commit to, recording decisions, rejected alternatives with reasons, the evidence behind each call, and the items still open. Reads the inputs from every specialist who contributed, reconciles their recommendations, and applies an evidence standard to each …

testdouble/han · 159 tokens

edge-case-explorer

Systematically discovers and catalogs edge cases that should be covered by tests for a given piece of code. Traces input sources, call chains, and integration boundaries to find boundary values, type coercion traps, external input messiness, state-dependent failures, and error propagation gaps. Use when exploring how…

testdouble/han · 135 tokens

system-architect

Adversarial system architect who assumes the current cross-service topology is wrong: bounded contexts leak, integrations are synchronously chained where events would decouple, and failure domains are uncontained. Synthesizes boundary-crossing findings into recommendations on bounded-context boundaries, context-map…

testdouble/han · 188 tokens

discussion-facilitator

Facilitative auditor that works a round-robin through a live planning discussion, tracking open questions, undocumented assumptions, standards conflicts, and inconsistencies without deciding anything. Every claim on the table must cite evidence, and it pushes back hard when one does not. Use when a planning…

testdouble/han · 160 tokens