AgentSkillsCN

Coding Style Analyzer

编码风格分析器

SKILL.md

Coding Style Analyzer Skill

Type: Meta-skill (generates other skills)
Purpose: Analyze your repositories, discover your coding style, generate a reusable skill
Status: Ready to use


Overview

This skill helps you create your own "your-coding-style" skill by:

  1. Scanning all your local repositories
  2. Asking intelligent questions about your coding philosophy
  3. Synthesizing patterns from your code + your answers
  4. Generating a reusable skill that codifies YOUR coding standards

The generated skill can then be used by other tools (like Claude Code, Ralph agents, etc.) to maintain consistency across all your projects.


How to Use

Step 1: Start the Analysis

Just say to Claude:

code
"Analyze my coding style"

Or with specific options:

code
"Analyze my coding style for ~/workspace and name it my-style"

Step 2: Provide Path

Claude will ask for the path to scan. Answer with:

code
~/workspace
~/projects
/Users/yourname/code

Step 3: Answer Questions

Claude will ask you ~15-20 questions about your coding philosophy:

  • Philosophy: What matters most? (performance, readability, maintainability, speed)
  • Naming: camelCase vs snake_case? How do you name booleans?
  • Functions: Target function length? Error handling strategy?
  • Testing: Coverage target? Unit vs integration ratio?
  • Architecture: Monorepo or separate? Folder structure?

Answer naturally. Your answers combined with your code patterns will form your style guide.

Step 4: Generated Skill

Claude generates:

code
~/.openclaw/workspace/skills/your-coding-style/
├── SKILL.md              (Instructions)
├── RULES.md              (Extracted rules with examples)
├── PROMPTS.md            (Claude prompts to enforce your style)
├── EXAMPLES.md           (Good/bad code examples)
├── style-guide.json      (Machine-readable rules)
└── metadata.json         (Analysis metadata)

What Gets Generated

RULES.md

Your extracted coding rules with good/bad examples:

markdown
## Naming Conventions
- Use camelCase for variables
- Use PascalCase for classes/components
- Booleans start with is, has, should

✓ const isActive = true
✗ const active = true

## Function Structure
- Max 50 lines of code
- Single responsibility principle
- Early returns to reduce nesting

✓ function process(data) {
    if (!data) return null;
    // ...
  }

PROMPTS.md

Claude system prompts that enforce your rules:

code
"You are a code generator familiar with [your-name]'s personal coding style.

Rules:
- Use camelCase for variables
- Keep functions under 50 LOC
- Write tests colocated with source
- ...

When generating code, follow these rules strictly."

EXAMPLES.md

Real code examples from your repositories showing your style in action.


How Claude Uses This

In Conversations

code
Claude: "I'll generate this code following your style guide:"
[generates code matching your patterns]

In Ralph Agents

json
{
  "system": "Follow the rules in ~/.openclaw/workspace/skills/your-coding-style/RULES.md"
}

In Other Skills

code
Reference: "Follow ~/openclaw/workspace/skills/your-coding-style/"

Updating Your Style

After 6 months of coding, run the analysis again:

code
"Update my coding style analysis"

Claude will:

  1. Re-scan your repositories
  2. Detect any pattern changes
  3. Ask updated questions
  4. Generate an improved skill
  5. Show you what changed

Example Output

When you run the analysis, you'll see:

code
✅ Scanning repositories...
✅ Found 340 files across 8 repositories
📊 Languages: TypeScript (280), Python (45), Rust (15)
🎯 Frameworks: React (6), Next.js (5), Vitest (7), Drizzle (4)

❓ Asking questions about your style...

✅ Style synthesized with 87% confidence

📝 Generating skill files...

✅ Skill generated successfully!

Location: ~/.openclaw/workspace/skills/your-coding-style/
Files:
   - SKILL.md
   - RULES.md
   - PROMPTS.md
   - EXAMPLES.md
   - style-guide.json
   - metadata.json

🎉 Your coding style skill is ready!

What Makes This Special

1. Discovers Your Actual Style

Not what you think your style is, but what your code actually shows:

  • 95% camelCase usage
  • Avg function length: 32 LOC
  • 70% colocated tests
  • Composition over inheritance

2. Combines Code + Philosophy

  • Code analysis: what you actually do
  • Your answers: why you do it
  • Result: comprehensive understanding

3. Machine-Readable Output

Generated style-guide.json can be parsed by:

  • Linters
  • Code formatters
  • Language models
  • Other tools

4. Polyglot Support

Works across TypeScript, Python, Go, Rust, Java, C#, JavaScript

5. Team-Ready

Generate team style: aggregate patterns across all developers


Questions You'll Be Asked

Philosophy (5 questions)

  • What matters most: performance, readability, maintainability, speed?
  • Your biggest pet peeve?
  • Minimalist or explicit?
  • Clever or obvious solutions?
  • Worst thing a developer can do?

Naming (5 questions)

  • Why camelCase? (if detected)
  • How do you name booleans?
  • When are abbreviations OK?
  • Single-letter variables: when?
  • Constant naming style?

Functions (5 questions)

  • Ideal function length?
  • Max parameters before using object?
  • Error handling: throw, return, Result type?
  • Comment strategy?
  • Max nesting depth?

Testing (5+ questions)

  • Coverage target?
  • Unit vs integration ratio?
  • Test location: colocated or separate?
  • Mocking strategy?
  • Testing framework preference?

Architecture (5 questions)

  • Monorepo or separate repos?
  • Folder structure: feature or type-based?
  • API design: REST, GraphQL, RPC?
  • Dependency injection?
  • Configuration management?

Success Criteria

The generated skill is successful when:

  • ✅ Claude can read and apply the rules
  • ✅ Generated code matches your patterns
  • ✅ Confidence score > 85%
  • ✅ Rules cover all major areas
  • ✅ Examples are illustrative and clear

Privacy & Security

  • ✅ Scans only YOUR local repositories
  • ✅ No code uploaded anywhere
  • ✅ Runs entirely on your machine
  • ✅ Output is local (~/.openclaw/workspace/skills/)
  • ✅ Can share skill without sharing code

Use Cases

Individual Developer

code
You → Analyze your repos
     → Get your-coding-style skill
     → Use in all new projects
     → Maintain consistency

Team

code
Team lead → Analyze all team repos
          → Generate team-coding-style
          → Share with team
          → All code consistent

Learning

code
Beginner → Analyze expert's repos
        → Study the generated skill
        → Learn expert's patterns
        → Apply to own code

Framework Authors

code
Generate react-best-practices-style
Generate django-web-style
Generate rust-systems-programming-style
Share with community

Troubleshooting

No repositories found

  • Check the path exists: ls ~/workspace
  • Path should contain subdirectories with code

Low confidence score (<70%)

  • Inconsistent patterns across repos
  • Conflicting answers
  • Not enough code to analyze
  • Try answering more specifically

Missing patterns in generated rules

  • Not enough code in that category
  • Patterns too varied
  • Consider providing explicit answers

Next Steps

  1. Run the analysis:

    code
    "Analyze my coding style for ~/workspace"
    
  2. Review the generated skill:

    code
    Open ~/.openclaw/workspace/skills/your-coding-style/RULES.md
    
  3. Use in your projects:

    code
    "Generate this feature following my coding style"
    
  4. Share with others:

    code
    Copy ~/.openclaw/workspace/skills/your-coding-style/ folder
    

Tools Used

This skill uses 4 main tools:

  1. scan-repositories - Analyzes your code for patterns
  2. ask-questions - Generates smart questions based on detected patterns
  3. synthesize-style - Merges code analysis + philosophy into rules
  4. generate-skill - Creates SKILL.md, RULES.md, and other files

Questions for Claude

Feel free to ask Claude:

  • "Analyze my coding style"
  • "Generate a style skill for ~/projects"
  • "Update my coding style analysis"
  • "What's my coding style based on analysis?"
  • "Generate code following my style"

Ready to discover your coding style? Ask Claude to analyze your repositories! 🚀