cook-refactor

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

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.

agentmods
npx agentmods add agents/johanthoren/jeff/cook-refactor
Clone the repo
git clone --depth 1 https://github.com/johanthoren/jeff
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. Scan, not verified.
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 $0.00039 $0.00861
Opus 5 $0.00019 $0.00430
Sonnet 5 $0.00008 $0.00172
Haiku 4.5 $0.00004 $0.00086

Measured 2d ago against content hash 750811f3f535, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 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.

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. 2d 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 (4 stars, last pushed 5d ago), licensed Apache-2.0. It adds 39 tokens to every session and 861 once invoked, about $0.0002 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.

Related

Other agents, from other repositories

codemap

Defines agent personalities (Orchestrator, Explorer, Librarian, etc.) and manages their configuration lifecycle. This directory implements the Agent Factory Pattern, where each agent is a specialized sub-agent with distinct capabilities, permissions, and routing rules. The Orchestrator agent (src/agents/index.ts)…

alvinunreal/oh-my-opencode-slim · 0 tokens

api-designer

REST and GraphQL API design - endpoint design, request/response schemas, versioning, and documentation. Use for designing new APIs or evolving existing ones.

AgentWorkforce/relay · 35 tokens

shep-web-route-creator

Scaffolds ONE new Next.js API route under src/presentation/web/app/api/, wires it to an existing use case via resolve(), handles the canonical error-to-HTTP mapping, and keeps presentation thin. Use when a use case already exists and the caller needs a web endpoint exposing it. Does NOT create the use case, does NOT…

shep-ai/shep · 85 tokens

python-pro

Python 3.13 language expert for the ClosedLoop plugin monorepo. Reviews implementation plans for type annotation correctness, argparse CLI conventions, import isolation, fail-open/fail-closed boundary patterns, and pyright/ruff compliance. Produces type-patterns.md in legacy mode.

closedloop-ai/claude-plugins · 60 tokens

config-safety-reviewer

Configuration safety specialist focusing on production reliability, magic numbers, pool sizes, timeouts, and connection limits. Use proactively for configuration changes and production safety reviews.

alirezarezvani/claude-code-tresor · 37 tokens

Audit

Deep security + performance audit of a specific diff. Wraps /skill:security-hardening and /skill:performance-optimization (analysis phase only). Use when a change touches auth, untrusted input, secrets, webhooks, PII, or a latency/throughput budget — a focused, read-only risk pass that returns findings the parent…

BlackBeltTechnology/pi-agent-dashboard · 98 tokens