Skip to main content
The Stats Tools provide command-line analysis utilities for your Claude Code components. Get detailed statistics on custom commands, automation hooks, and MCP server configurations with token estimates and optimization suggestions.

Command Stats

Analyze custom slash commands in your project.

Run Analysis

Example Output:

Features

Metrics calculated::lines/command-stats.js:63
  • File size (KB)
  • Line count
  • Word count
  • Token estimate
  • Last modified date
  • Command title/description
Token estimation::lines/command-stats.js:12
  • Base: ~4 characters per token
  • Code blocks: +5 tokens each
  • Inline code: +2 tokens each
  • Markdown elements: +0.5 tokens each

Optimization Prompt

After displaying statistics, you’re prompted:lines/command-stats.js:234
Accepting launches Claude with a detailed prompt:lines/command-stats.js:302 Optimization prompt includes:
  1. Project structure review
  2. Technology stack detection
  3. Command relevance analysis
  4. Improvement suggestions
  5. Missing command recommendations
  6. Project-specific customization

No Commands Found

If no .claude/commands/ directory exists:lines/command-stats.js:194

API Usage

Hook Stats

Analyze automation hooks configured in settings.json.

Run Analysis

Example Output:

Features

Hook data extracted::lines/hook-stats.js:59
  • Hook name
  • Hook type (PreToolUse, PostToolUse, Stop, Notification)
  • Description
  • Enabled/disabled status
  • Script/command content
  • Configuration size
  • Token estimate
Hook types supported::line/hook-stats.js:50
  • PreToolUse: Runs before tool execution
  • PostToolUse: Runs after tool execution
  • Stop: Runs when conversation stops
  • Notification: Sends notifications

Optimization Prompt

After analysis:lines/hook-stats.js:197
Optimization areas::lines/hook-stats.js:222
  1. Hook efficiency and performance
  2. Missing hooks for workflow
  3. Redundant or conflicting hooks
  4. Hook organization best practices
  5. Security considerations
  6. Condition and trigger optimization

No Hooks Found

If no hooks configured:lines/hook-stats.js:173

API Usage

MCP Stats

Analyze MCP server configurations in .mcp.json.

Run Analysis

Example Output:

Features

Server data extracted::lines/mcp-stats.js:34
  • Server name and key
  • Command and arguments
  • Environment variables
  • Enabled/disabled status
  • Category (auto-detected)
  • Configuration complexity
Category detection::lines/mcp-stats.js:71 Based on server name, command, and description:
  • IDE & Development
  • Database
  • Web & API
  • Filesystem
  • DevOps
  • AI & ML
  • Other
Complexity calculation::lines/mcp-stats.js:115 Factors:
  • Arguments present (+1)
  • Environment variables (+1)
  • Settings object (+1)
  • High env var count (+1-2)
  • Capped at 5 stars

Optimization Prompt

After analysis:lines/mcp-stats.js:258
Optimization areas::lines/mcp-stats.js:284
  1. Server selection and workflow relevance
  2. Missing MCP servers for productivity
  3. Configuration optimization (command, args, env)
  4. Performance and resource usage
  5. Security best practices
  6. Redundant or conflicting servers
  7. Integration opportunities

No MCPs Found

If no .mcp.json file:lines/mcp-stats.js:233

API Usage

Common Patterns

Audit All Components

Generate Component Report

Pre-commit Hook

Add to .git/hooks/pre-commit:

Token Estimation

All stats tools include token estimation:lines/command-stats.js:12 Algorithm:
Use cases:
  • Estimate prompt size
  • Optimize command length
  • Track token consumption trends

Troubleshooting

Command Not Found

Error: No .claude/commands directory found Create directory:

Invalid JSON

Error: Error reading settings.json Validate JSON:

Hook Command Validation

Hooks validated with command -v:lines/hook-stats.js:1089

MCP Category Detection

If category is β€œOther”, improve detection:lines/mcp-stats.js:71
Include keywords: database, postgres, mysql, sqlite

See Also