refactor-analyze.template

refactor-analyze.template is a command for coding agents from evan043/claude-cli-advanced-starter-pack. It costs 0 tokens per session (11,206 once invoked), scanned B, original, MIT.

A code-analysis command that measures complexity, finds code smells, and traces dependencies between parts of a project.

In plain words
What is it for?
Use it to analyze one file, a directory, or the whole project and rank likely refactoring candidates.
Why use it?
It helps identify which refactoring tasks are most important instead of relying on guesswork.

Command

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 commands/evan043/claude-cli-advanced-starter-pack/refactor-analyze.template
Clone the repo
git clone --depth 1 https://github.com/evan043/claude-cli-advanced-starter-pack

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 refactor-analyze.template

README.md
[![agentmods](https://agentmods.dev/badge/commands/evan043/claude-cli-advanced-starter-pack/refactor-analyze.template.svg)](https://agentmods.dev/commands/evan043/claude-cli-advanced-starter-pack/refactor-analyze.template)
Your own site
<a href="https://agentmods.dev/commands/evan043/claude-cli-advanced-starter-pack/refactor-analyze.template"><img src="https://agentmods.dev/badge/commands/evan043/claude-cli-advanced-starter-pack/refactor-analyze.template.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 11,206 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00000 $0.11206
Opus 5 $0.00000 $0.05603
Sonnet 5 $0.00000 $0.02241
Haiku 4.5 $0.00000 $0.01121

Measured 5d ago against content hash ffedb448587f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

refactor-analyze.template scanned grade B with 1 finding 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 5d 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

cat .claude/refactor-analysis/refactor-analysis-{date}/By-Page/epg/fix-order.yaml
templates/commands/refactor-analyze.template.md · 1,357 lines

How it starts

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

Codex Runtime Compatibility

This prompt was authored for Claude-style slash workflows. In Codex runtime, adapt tool calls as follows:

  • AskUserQuestion => ask the user directly in chat.
  • WebSearch/WebFetch => use available web tools (search_query, open, find) and cite links.
  • Read/Write => use shell/filesystem tools in this workspace.
  • Claude-only MCP calls (for example Playwright MCP names) => use available equivalents or clearly state fallback.
  • Keep intent and output format identical; only adapt execution mechanics.

description: Deep complexity analysis for refactoring prioritization with dependency tracing model: sonnet argument-hint: [file path, directory, or 'all']

/refactor-analyze - Code Complexity Analysis

Analyze code complexity, detect code smells, and prioritize refactoring candidates with metrics-driven recommendations. Now with dependency tracing and global scanning.

Quick Start

/refactor-analyze                     # Interactive mode - choose options
/refactor-analyze src/api/            # Analyze specific directory
/refactor-analyze src/api/client.ts   # Analyze single file
/refactor-analyze --top 10            # Show top 10 worst files
/refactor-analyze --trace-imports     # Trace full import dependency tree
/refactor-analyze --global-scan       # Find ALL large files (not just flagged)
/refactor-analyze --threshold 1000    # Custom line threshold (default: 500)

Instructions for Claude

When /refactor-analyze is invoked, ALWAYS start with Step 0 to present interactive options.

Step 0: Present Interactive Options (REQUIRED)

Use AskUserQuestion to let the user configure the analysis:

questions:
  - header: "Analysis Mode"
    question: "What type of analysis do you want to run?"
    multiSelect: false
    options:
      - label: "Standard Analysis (Recommended)"
        description: "Analyze flagged files (>500 lines) with basic metrics"
      - label: "Deep Analysis + Import Tracing"
        description: "Trace full dependency tree for each file - discovers hidden large dependencies"
      - label: "Global Scan"
        description: "Find ALL files above threshold regardless of page association"
      - label: "Comprehensive (All Features)"
        description: "Global scan + import tracing + orphan detection"

  - header: "Line Threshold"
    question: "What line count threshold should trigger analysis?"
    multiSelect: false
    options:
      - label: "500 lines (Standard)"
        description: "Default threshold - catches most problem files"
      - label: "1000 lines (Large files only)"
        description: "Focus on the biggest offenders first"
      - label: "2000 lines (Critical only)"
        description: "Only truly massive files needing immediate attention"
      - label: "300 lines (Strict)"
        description: "More aggressive - catch problems earlier"

  - header: "Output Format"
    question: "How should results be organized?"
    multiSelect: false
    options:
      - label: "By Priority Score (Recommended)"
        description: "Rank all files by refactoring urgency"
      - label: "By Page/Route"
        description: "Group files by their consuming page entry points"
      - label: "By Discovery Method"
        description: "Separate direct flags, import traces, and global scan results"

Read the full file on GitHub · 1,357 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. 5d ago First seen · 1,357 lines · 0 tokens per session scan B ffedb448587f

Subscribe to this mod's changes

refactor-analyze.template is a command published in the GitHub repository evan043/claude-cli-advanced-starter-pack (61 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 11,206 tokens. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.