claudemd-refactor

Refactor and optimize CLAUDE.md files in a repository. Analyzes the existing setup, explores repo structure, proposes splitting CLAUDE.md into a hierarchical directory-scoped structure. Use when: (1) User wants to optimize CLAUDE.md, (2) Root CLAUDE.md is too large, (3) User wants to split CLAUDE.md into directory-scoped files, (4) User mentions 'refactor CLAUDE.md', 'split CLAUDE.md', or 'organize CLAUDE.md'.

6 stars

Best use case

claudemd-refactor is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Refactor and optimize CLAUDE.md files in a repository. Analyzes the existing setup, explores repo structure, proposes splitting CLAUDE.md into a hierarchical directory-scoped structure. Use when: (1) User wants to optimize CLAUDE.md, (2) Root CLAUDE.md is too large, (3) User wants to split CLAUDE.md into directory-scoped files, (4) User mentions 'refactor CLAUDE.md', 'split CLAUDE.md', or 'organize CLAUDE.md'.

Teams using claudemd-refactor should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/claudemd-refactor/SKILL.md --create-dirs "https://raw.githubusercontent.com/Takazudo/claude-resources/main/skills/claudemd-refactor/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/claudemd-refactor/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How claudemd-refactor Compares

Feature / Agentclaudemd-refactorStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Refactor and optimize CLAUDE.md files in a repository. Analyzes the existing setup, explores repo structure, proposes splitting CLAUDE.md into a hierarchical directory-scoped structure. Use when: (1) User wants to optimize CLAUDE.md, (2) Root CLAUDE.md is too large, (3) User wants to split CLAUDE.md into directory-scoped files, (4) User mentions 'refactor CLAUDE.md', 'split CLAUDE.md', or 'organize CLAUDE.md'.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Refactor CLAUDE.md

Analyze and refactor CLAUDE.md files in the current repository to optimize how context is delivered to Claude Code.

## Context Loading Reliability Hierarchy

When deciding where to place information, follow this hierarchy (most to least reliable):

| Approach | Reliability | Tradeoff |
|---|---|---|
| Inline in CLAUDE.md | Highest | Larger CLAUDE.md |
| Directory-scoped CLAUDE.md | High | Content must be relevant to that directory |
| Explicit "read before doing X" | Medium | Depends on Claude following the instruction |
| Passive "refer to file" | Low | Claude may or may not read it |

**Key principle**: Claude Code automatically loads CLAUDE.md files based on the working directory. Root CLAUDE.md is always loaded. Subdirectory CLAUDE.md files are loaded when working on files in that directory. Content in CLAUDE.md is always in context — no tool call needed.

## Workflow

### Phase 1: Explore and Analyze

1. **Find all existing CLAUDE.md files** in the repo

   ```
   Glob: **/CLAUDE.md
   ```

2. **Read the root CLAUDE.md** — understand what's currently there, measure its size

3. **Explore the repo structure** — understand the directory layout, identify logical boundaries
- What are the major directories? (src/, docs/, scripts/, tests/, etc.)
- What languages/frameworks are used?
- Are there distinct subsystems with their own conventions?

4. **Categorize the content** in the existing root CLAUDE.md into buckets:
- **Global**: Project-wide info that applies everywhere (project name, tech stack, overall architecture, global conventions)
- **Directory-specific**: Rules that only apply to certain directories (e.g., "use camelCase in src/", "frontmatter required in docs/")
- **Task-specific**: Instructions tied to specific operations (e.g., "before modifying API routes, read api-design.md")
- **Redundant/outdated**: Content that can be removed

### Phase 2: Propose a Plan

Present the user with a concrete proposal. Include:

1. **Current state summary**
- Number of CLAUDE.md files found
- Root CLAUDE.md size (lines/sections)
- Content categories identified

2. **Proposed CLAUDE.md structure** — show a tree like:

   ```
   repo/
   ├── CLAUDE.md              # Global: project overview, tech stack, universal conventions
   ├── src/
   │   └── CLAUDE.md          # Code: naming conventions, import rules, architecture patterns
   ├── docs/
   │   └── CLAUDE.md          # Docs: writing style, frontmatter, formatting rules
   └── tests/
       └── CLAUDE.md          # Tests: testing conventions, fixture locations, coverage rules
   ```

3. **For each proposed CLAUDE.md**, list:
- What content moves there (with specific sections/lines from original)
- What stays in root
- Any new content needed (e.g., cross-references)

4. **Migration of "refer to" patterns** — identify any passive references and propose upgrades:
- Passive → Inline (if content is small and critical)
- Passive → Explicit trigger ("Before modifying X, read Y")
- Keep as passive (only if truly optional background info)

### Phase 3: Ask for User Approval

**IMPORTANT**: Do NOT proceed without explicit user approval. Present the plan and ask:

- Does the proposed structure make sense for this repo?
- Should any content stay in root instead of being split?
- Are there directories that should have their own CLAUDE.md that weren't identified?
- Any content that should be removed entirely?

### Phase 4: Execute the Refactoring

After approval:

1. **Create directory-scoped CLAUDE.md files** with the approved content
2. **Trim the root CLAUDE.md** — remove content that was moved to subdirectories
3. **Upgrade passive references** — replace "refer to X" with inline content or explicit triggers
4. **Add cross-references where needed** — if root CLAUDE.md needs to mention that subdirectory rules exist

### Phase 5: Verify

1. Read each created/modified CLAUDE.md to verify correctness
2. Ensure no critical information was lost
3. Check that the root CLAUDE.md is noticeably smaller but still contains all global info
4. Present a summary of changes to the user

## Content Placement Rules

Use these rules to decide where content belongs:

### Root CLAUDE.md (always loaded)

- Project name and purpose
- Tech stack overview
- Universal coding conventions (applies to ALL code)
- Git/commit conventions
- CI/CD and deployment notes
- Links to key documentation
- Cross-references to subdirectory CLAUDE.md files

### Directory-scoped CLAUDE.md (loaded when working in that directory)

- Language/framework-specific conventions for that directory
- File naming and organization rules specific to that area
- Import/export patterns
- Testing patterns specific to that area
- Build/compilation notes for that subsystem

### What NOT to put in CLAUDE.md

- Content that changes frequently (use external docs with explicit read triggers)
- Very long reference material (keep in separate .md files, use explicit read triggers)
- Information that's obvious from the code itself

## Anti-patterns to Fix

When analyzing existing CLAUDE.md, look for and fix these anti-patterns:

1. **"Refer to X for details"** → Inline the content or use explicit trigger
2. **Duplicate information** across multiple sections → Consolidate
3. **Outdated instructions** referencing files/dirs that don't exist → Remove
4. **Overly verbose explanations** → Condense to actionable rules
5. **Everything in root** when clear directory boundaries exist → Split
6. **Directory-specific rules in root** → Move to appropriate directory CLAUDE.md

Related Skills

retro-notes-refactor

6
from Takazudo/claude-resources

Refactor an accumulated `l-lessons-*` skill (created by /retro-notes) when later entries partially supersede or extend earlier ones, so future planning agents see the cross-cutting wisdom first instead of having to read every dated entry. Use when (1) the user says "lessons refactor", "retro refactor", "retro-notes refactor", "refactor lessons", or "synthesize lessons", (2) a `/retro-notes` session just added a new dated entry that broadens / narrows / contradicts a claim in an earlier entry on the same area, (3) an `l-lessons-*/SKILL.md` has 5+ dated entries on the same problem area OR exceeds ~500 lines, (4) the next `/big-plan` run in that area would have to scan many entries to find the relevant pattern. Produces a top-of-file "Recurring patterns (synthesized)" section in Trigger/Action/See format, adds Caveat notes to entries whose claims were later widened, updates the frontmatter description with pattern keywords, and formats with mdx-formatter. Does NOT delete historical entries — they remain as terse drill-down postmortems. Pair with /retro-notes (which writes new entries) and /big-plan (which reads the synthesized section first).

zudoesa-articlify

6
from Takazudo/claude-resources

Convert conversation context into an esa article via the zudoesa-writer subagent. ONLY invoke when the user explicitly asks — NEVER proactively propose. Triggers: 'write esa article', 'esa記事', 'esaに書いて', 'articlify for esa', or /zudoesa-articlify. Gathers context, creates a writing brief, delegates to the writer subagent.

zudoesa-apply-voice

6
from Takazudo/claude-resources

Apply Takazudo's esa writing voice and vocabulary rules to text. Use when: (1) User wants to write/rewrite text in Takazudo's esa style, (2) User says 'apply voice', 'esa voice', 'esa文体で', 'esa風に書いて', '文体を適用', (3) User provides text to transform to esa style. Reads writing-style.md and vocabulary-rule.md from takazudo-esa-writing repo and applies the rules.

zudocg-articlify

6
from Takazudo/claude-resources

Convert conversation context into a CodeGrid article via the zudocg-writer subagent. ONLY invoke when the user explicitly asks — NEVER proactively propose. Triggers: 'write codegrid article', 'CodeGrid記事', 'codegridに書いて', 'articlify for codegrid', or /zudocg-articlify. Gathers context, creates a writing brief, delegates to the writer subagent.

zudocg-apply-voice

6
from Takazudo/claude-resources

Apply Takazudo's CodeGrid writing voice and vocabulary rules to text. Use when: (1) User wants to write/rewrite text in Takazudo's CodeGrid style, (2) User says 'apply voice', 'codegrid voice', 'codegrid文体で', 'codegrid風に書いて', '文体を適用', (3) User provides text to transform to CodeGrid style. Reads writing-style.md and vocabulary-rule.md from takazudo-codegrid-writing repo and applies the rules.

zpaper-articlify

6
from Takazudo/claude-resources

Convert conversation context into a zpaper blog article via the zpaper-writer subagent. ONLY invoke when the user explicitly asks — NEVER proactively propose. Triggers: 'write zpaper article', 'zpaper記事', 'zpaperに書いて', 'articlify for zpaper', or /zpaper-articlify. Gathers context, creates a writing brief, delegates to the writer subagent.

zpaper-apply-voice

6
from Takazudo/claude-resources

Apply Takazudo's zpaper blog writing voice and vocabulary rules to text. Use when: (1) User wants to write/rewrite text in Takazudo's zpaper style, (2) User says 'apply voice', 'zpaper voice', 'zpaper文体で', 'zpaper風に書いて', 'ブログ文体を適用', (3) User provides text to transform to zpaper style. Reads writing-style.md and vocabulary-rule.md from the zpaper repo and applies the rules.

xlsx

6
from Takazudo/claude-resources

Spreadsheet creation, editing, and analysis. Use when working with .xlsx, .xlsm, .csv, .tsv files for: (1) Creating spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modifying existing spreadsheets while preserving formulas, (4) Data analysis and visualization, (5) Recalculating formulas.

x

6
from Takazudo/claude-resources

Facade for development workflows. Routes on two axes: plan-first vs implement-now (escalates to /big-plan -a when the request needs research / decomposition / has unclear scope — the appended -a makes the plan chain into implementation in-session), then single vs multi on the ready-to-build fast paths (/x-as-pr single-topic, /x-wt-teams multi-topic parallel). Use when: (1) User says '/x' followed by dev instructions, (2) User wants to start development without choosing the workflow skill, (3) User says 'dev', 'implement', or 'build' with a task. Default option: -v (verify-ui). Review-loop (-l) is opt-in — without -l the downstream skill runs a single /deep-review pass. Forwards -a (autonomy/auto-chain) and -m (merge at the end + cleanup + CI watch) through every route; auto-fix of raised findings (-f) and issue-raising (-ri) are downstream defaults, with -nf/--no-fix and -nori/--no-raise-issues as the forwarded opt-outs. -a and -m are orthogonal — full hands-off end-to-end is -a -m.

x-wt-teams

6
from Takazudo/claude-resources

Parallel multi-topic development using git worktrees, base branches, and Claude Code agent teams. Use when: (1) User wants to work on multiple related features in parallel, (2) User mentions 'worktree', 'base branch', 'parallel development', 'split into topics', or 'multi-topic'. FULLY AUTONOMOUS — creates worktrees, spawns teams, coordinates everything. Also supports Super-Epic child mode for [Epic] issues from /big-plan with '**Super-epic:** #N' markers (targets the super-epic base branch instead of main).

x-as-pr

6
from Takazudo/claude-resources

Start a development workflow as a draft PR. Creates a NEW branch from the current branch, empty start commit, draft PR targeting the current branch, then implements. ALWAYS creates a new branch by default — produces a nested PR-on-PR when the current branch already has one. Use when: (1) User says 'dev as pr', (2) User wants a PR-first workflow before coding, (3) User passes -s/--stay to reuse the current branch instead of nesting, (4) User passes a GitHub issue URL to implement, (5) User passes --make-issue/--issue to create an issue first. Logs progress via issue comments when an issue is linked.

watch-ci

6
from Takazudo/claude-resources

Watch GitHub PR CI checks in the background and notify on completion. Use when: (1) User wants to monitor CI/CD status, (2) User says 'watch CI', 'check CI', 'monitor checks', or 'wait for CI', (3) User wants to know when checks pass or fail. Runs a background gh polling shell loop (NOT a subagent — near-zero token cost), sends macOS notification on completion. Also handles merged PRs by watching the target branch CI.