plan

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

A command for creating an ordered plan for safely refactoring code, meaning changing its internal structure without intentionally changing its behavior.

In plain words
What is it for?
Use it after analysing a refactoring target to document the goal, scope, risks, required tests, and execution steps.
Why use it?
It turns a broad refactoring task into checked preparation steps and smaller implementation phases.

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 after analysing a refactoring target to document the goal, scope, risks, required tests, and execution steps.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/commands/juanmhidalgo/claude-plugins/plan"><img src="https://agentmods.dev/badge/commands/juanmhidalgo/claude-plugins/plan.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 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,971 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.00036 $0.01971
Opus 5.5 $0.00014 $0.00788
Sonnet 5.5 $0.00007 $0.00394
Haiku 4.5 $0.00004 $0.00197

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

Security

Grade A, and why

plan 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/plan.md · 220 lines

How it starts

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

Refactoring Plan

Recommended: run in plan mode (Shift+Tab to toggle) so the proposed plan is reviewed before any code changes.

Create a structured refactoring plan.

Target: $ARGUMENTS

Phase 1: Gather Context

Agent — subagent_type: "refactor:refactor-planner" (skip only if a recent analysis already covers this) to understand:

  1. What needs to be refactored and why
  2. Current test coverage
  3. Dependencies that could break
  4. Similar refactorings done in this project

Agent — subagent_type: "refactor:conflict-scout", always. Pass:

  • Targets: every file and directory the refactor will touch — including the consumers that a rename would reach, not just the file being restructured.
  • Symbols: the names you expect to rename, move, or delete. Leave empty only if the refactor genuinely renames nothing; the semantic-overlap scan is the half git cannot do for you.

A plan written without this scan orders the work by internal risk alone and ignores the only cost that grows while you work: someone else's branch drifting away from yours.

Phase 2: Clarify Scope

  • "What's the primary goal: reduce complexity, improve testability, or prepare for a new feature?"
  • "Are there parts of the code that must NOT change?"
  • "What's the acceptable risk level: conservative or aggressive?"

Phase 3: Generate Plan

<output_format>

# Refactoring Plan: [target]

## Goal
[One sentence describing the end state]

## Scope
- **In scope**: [what will change]
- **Out of scope**: [what stays unchanged]
- **Risk level**: Low / Medium / High

## Concurrent Work

From the conflict scout. State its verdict verbatim; if it could not reach `gh`, say so instead of claiming a clean scan.

**Verdict**: CLEAR | CONTESTED | BLOCKED — [one sentence]

| Target | Concurrent work | Type | Handling |
|--------|-----------------|------|----------|
| `path` | PR #N "title" (@author, 12d, +340/-120) | textual — same functions | defer to Phase 3, after #N merges |
| `symbol` | PR #N calls it in `path:line` | semantic — merges clean, breaks after | land after #N, or tell @author |
| `path` | uncommitted local edits | local | commit or stash in the pre-flight checklist |

(If nothing is in flight, write exactly: "No open PRs, branches, or local edits touch these files.")

## Call Sites

Every reference to a symbol being renamed, moved, or deleted, found with Grep (not sampled). The user checks this list to confirm nothing was missed.

| Symbol | Call site | Step that updates it |
|--------|-----------|----------------------|
| `old_name` | `path/to/file.py:42` | 2.2 |
| `old_name` | `templates/x.html:7` (string reference) | 2.2 |

**Total**: [N] call sites in [M] files. Searched: [the exact patterns used, including string/dynamic forms such as `getattr`, templates, config]

(If the refactor renames, moves, or deletes nothing, write exactly: "No symbols change name or location.")

## Execution Mode

- **Step by step** (default): follow the phases below
- **Hand off to `/batch`**: when the migration is mechanical and touches many files (roughly 10+ files, or call sites that can each be updated independently), offer the built-in `/batch <instruction>`; it splits the work into independent units, each in its own worktree. Pass it this plan's Goal, the Call Sites table, and the checkpoints. Not for steps that must land in order

## Pre-Refactoring Checklist
- [ ] Tests pass before starting
- [ ] Branch rebased on the latest base — a refactor started behind conflicts twice
- [ ] Git branch created: `refactor/[name]`
- [ ] Backup or stash any uncommitted work
- [ ] Contested files from Concurrent Work confirmed still contested (PRs move fast; re-check `gh pr list` if the plan is more than a day old)

## Steps

### Phase 1: Preparation (Low Risk)
No behavior changes - just setup.

#### Step 1.1: [Add missing tests]
- **Files**: `test_file.py`
- **What**: Add tests for [uncovered behavior]
- **Why**: Safety net before changes
- **Checkpoint**: Run tests, should pass

#### Step 1.2: [Extract constants]
- **Files**: `file.py`
- **What**: Move magic numbers to named constants
- **Why**: Makes next steps easier
- **Checkpoint**: Tests pass, no behavior change

### Phase 2: Core Refactoring (Medium Risk)
Main structural changes.

#### Step 2.1: [Extract function/class]
- **Files**: `file.py`
- **What**: Extract [code block] into [new_function]
- **How**:
  1. Create new function with signature
  2. Move code
  3. Replace original with call
  4. Run tests
- **Checkpoint**: Tests pass

#### Step 2.2: [Rename for clarity]
...

### Phase 3: Cleanup (Low Risk)
Polish and documentation.

#### Step 3.1: [Remove dead code]
...

#### Step 3.2: [Update documentation]
...

## Conflict Handling

For each contested target, the plan commits to one of these — never leaves it implicit:

| Situation | Move |
|-----------|------|
| PR is small and young (<3 days, <10 files) | Do that target **first and now**; land the refactor before the PR grows |
| PR is large or long-lived | **Defer** the target to a later phase; note "blocked on #N" on the step |
| PR only *calls* a symbol being renamed | Keep a **deprecation shim** (old name delegating to new) until #N merges, then remove it in a cleanup step |
| Work is local and yours | Commit or stash it in the pre-flight checklist — no plan step needed |

A step that touches a contested file carries `**Blocked on**: PR #N` on its own line, so it is visible when the step is dispatched, not only here.

## Rollback Plan
If something goes wrong:
1. `git stash` current changes
2. `git checkout <base-branch>`
3. Investigate what broke
4. Either fix forward or abandon

## Success Criteria
- [ ] All tests pass
- [ ] [Specific metric improved: e.g., function <30 lines]
- [ ] No new linter warnings
- [ ] Code review approved

## Estimated Effort
| Phase | Time | Risk |
|-------|------|------|
| Phase 1 | [X hours] | Low |
| Phase 2 | [X hours] | Medium |
| Phase 3 | [X hours] | Low |
| **Total** | [X hours] | |

</output_format>

Read the full file on GitHub · 220 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 · +22 lines dbbc061f03c4
  2. 23d ago Changed 5cddac6be063
  3. 1mo ago Changed · +45 lines 426efc246c34
  4. 1mo ago First seen · 153 lines · 36 tokens per session scan A 358b926b294e

Subscribe to this mod's changes

plan is a command published in the GitHub repository juanmhidalgo/claude-plugins (8 stars, last pushed 2d ago), licensed MIT. It adds 36 tokens to every session and 1,971 once invoked, about $0.0001 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.