context-optimizer

Analyze CLAUDE.md and extract rules and skills into frontmatter-compliant files.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/swat9013/dotfiles --skill context-optimizer-swat9013
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-optimizer
Source: https://github.com/swat9013/dotfiles/tree/main/.claude-global/skills/context-optimizer
Command: npx skills add https://github.com/swat9013/dotfiles --skill context-optimizer-swat9013

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Reduces oversized CLAUDE.md files and minimizes unnecessary context consumption so AI sessions load only the essential project guidance and avoid token waste.

Core Features & Use Cases

  • Analysis: Counts CLAUDE.md and .claude/ markdown lines, reports ratios, and flags files exceeding recommended thresholds using the provided analysis script.
  • Classification & Extraction Planning: Classifies sections into rules, skills, or CLAUDE.md retention, and generates an extraction plan with target paths and frontmatter guidance.
  • Refactor & Validation: Produces frontmatter-compliant files for rules/ and skills/, compresses CLAUDE.md to core essentials, and validates frontmatter, description style, and reference depth using templates and checklists.
  • Use Case: Convert a monolithic CLAUDE.md into a 30-line project summary while extracting coding rules to rules/typescript.md and workflows to skills/review-fix/SKILL.md for clearer, token-efficient AI prompts.

Quick Start

Run the context optimizer to analyze CLAUDE.md and propose extraction and refactor steps using the included analysis script and templates.

Frequently Asked Questions about context-optimizer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce CLAUDE.md file size to optimize context usage for AI sessions?

To optimize context usage, you can extract coding rules and workflows from CLAUDE.md into separate frontmatter-compliant files under the .claude/ directory. This minimizes token waste by compressing the main file to core essentials while retaining project guidance.

What is the recommended line count threshold for a CLAUDE.md file?

The recommended line count threshold is determined by analyzing your CLAUDE.md and .claude/ directory markdown lines. The context optimizer flags files exceeding recommended limits to prevent unnecessary token consumption during AI sessions.

How do I extract coding rules from a monolithic CLAUDE.md into the .claude/ directory?

You extract coding rules from CLAUDE.md by classifying sections into rules or skills, generating an extraction plan with target paths, and creating frontmatter-compliant files like rules/typescript.md or skills/review-fix/SKILL.md using provided templates.

Can I analyze my repository context distribution before refactoring CLAUDE.md?

Yes, you can analyze context distribution before refactoring CLAUDE.md by running the analyze-context.sh script. It counts markdown lines, reports ratios between CLAUDE.md and .claude/ files, and flags oversized files exceeding recommended thresholds.

How do I validate extracted rules and skills files after splitting CLAUDE.md?

You validate extracted rules and skills files by checking frontmatter compliance, description style, and reference depth using provided templates and checklists. This ensures the newly created files in the .claude/ directory meet formatting standards.

Why does my CLAUDE.md consume too many tokens during AI coding sessions?

Your CLAUDE.md consumes excessive tokens during AI sessions because it likely contains oversized, monolithic content. Extracting rules and workflows into structured .claude/ files reduces context consumption by loading only essential project guidance.