extract

extract is a command for Claude Code from juanmhidalgo/claude-plugins. It costs 38 tokens per session (1,181 once invoked), scanned A, original, MIT.

A command for safely moving a known piece of code into a reusable function, class, or module while accounting for its tests, name, location, inputs, outputs, and side effects.

In plain words
What is it for?
Use it when you already know what to extract and need help choosing its boundaries, placement, name, and required test updates.
Why use it?
It reduces mistakes when separating code from its original location and updating the code that used it.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool.

Part of the refactor plugin — 2 commands, 3 agents shipped together

Good fit Use it when you already know what to extract and need help choosing its boundaries, placement, name, and required test updates.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/juanmhidalgo/claude-plugins/extract
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/juanmhidalgo/claude-plugins

Made for: Claude Code.

Or install refactor, the plugin that ships this one along with the rest of its 2 commands, 3 agents.

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 extract

README.md
[![agentmods](https://agentmods.dev/badge/commands/juanmhidalgo/claude-plugins/extract/github.svg)](https://agentmods.dev/commands/juanmhidalgo/claude-plugins/extract)
Your own site
<a href="https://agentmods.dev/commands/juanmhidalgo/claude-plugins/extract"><img src="https://agentmods.dev/badge/commands/juanmhidalgo/claude-plugins/extract/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 extract

Your own site · 80×15
<a href="https://agentmods.dev/commands/juanmhidalgo/claude-plugins/extract"><img src="https://agentmods.dev/badge/commands/juanmhidalgo/claude-plugins/extract.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,181 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.00038 $0.01181
Opus 5.5 $0.00015 $0.00472
Sonnet 5.5 $0.00008 $0.00236
Haiku 4.5 $0.00004 $0.00118

Measured 14d ago against content hash 8522b325e75f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

extract 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 14d 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.

refactor/commands/extract.md · 167 lines

How it starts

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

Code Extraction

Safely extract code into a reusable unit.

What to extract: $ARGUMENTS

Phase 1: Understand the Context

  1. The code to extract (if not specified precisely)
  2. Where similar extractions live in this project
  3. Naming conventions for functions/classes/modules
  4. Test files that need updating

Phase 1.5: Conflict Check

<conflict_check> Extraction rewrites existing lines, so any open PR touching the same file will conflict. One call, before you clarify anything:

gh pr list --state open --limit 40 --json number,title,author,isDraft,updatedAt,files \
  --jq '.[] | select(.files[].path | test("<source-file>|<destination-file>")) | {number, title, author: .author.login, isDraft, updatedAt}'
git status --porcelain -- <source-file> <destination-file>

Act on the result:

Result Action
No open PR, clean status Proceed to Phase 2
Uncommitted local edits Tell the user; offer to commit or stash first
An open PR touches the file Stop and surface it — PR number, title, author, age. Use AskUserQuestion: extract now and accept the conflict, extract a different piece, or wait for the PR to merge. Do not decide this silently
A PR calls the symbol you are moving but does not touch these files Surface it too — the move merges clean and breaks that PR at runtime. Keep the old name as a shim, or wait
gh missing or unauthenticated Say so and continue on the local check alone — do not report the file as clear

</conflict_check>

Phase 2: Clarify Extraction

Question Impact if wrong Default
Extract as function, class, or module? Structure mismatch Function if <50 lines
Placement - same file or new file? Import complexity Same file if related
Name for the extracted code? Discoverability [Suggest based on content]

Read the full file on GitHub · 167 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. 14d ago Changed · +2 lines 8522b325e75f
  2. 23d ago Changed · -24 lines 525277dd4493
  3. 1mo ago Changed · +29 lines d689f923a9a4
  4. 1mo ago First seen · 160 lines · 38 tokens per session scan A 7a9be3e0e0c2

Subscribe to this mod's changes

extract is a command published in the GitHub repository juanmhidalgo/claude-plugins (8 stars, last pushed 2d ago), licensed MIT. It adds 38 tokens to every session and 1,181 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-09-03.