/software-engineering:gen-claude [--force] [--template=minimal|standard|comprehensive] [--no-docs] [--dry-run]from software-engineering
Generates or enhances CLAUDE.md with project-specific guidance via deep codebase analysis. Detects languages, frameworks, build tools, and linter configs to create optimized documentation.
Ships in software-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Automatically generate or enhance a project-specific CLAUDE.md file following 2025-2026 best practices. This skill performs deep codebase analysis to create comprehensive project documentation that stays within the 2500 token limit.
Problem: Projects often lack CLAUDE.md files or have poorly structured ones, forcing Claude to operate without project-specific context.
Solution: Automated generation that:
CRITICAL: When generating any content (CLAUDE.md, docs/, commit messages, descriptions, or any other output):
Launch 4 independent agents concurrently to analyze different aspects of the project:
Agent #1: Project Structure Analyzer
Task(subagent_type: "Explore", model: "sonnet", prompt: "
Analyze project structure and return JSON:
{
languages: [list of detected languages from file extensions],
frameworks: [frameworks/libraries detected from imports/configs],
buildTool: string (npm/go/cargo/maven/gradle/make/task/etc),
buildCommands: {build: '', test: '', lint: '', run: ''},
structure: {
source: path,
tests: path,
docs: path,
config: path
}
}
Detection strategy:
- Languages: Glob for *.go, *.js, *.py, *.rs, *.java, *.rb, *.php
- Build tools: Look for package.json, go.mod, Cargo.toml, requirements.txt, pom.xml, build.gradle, Makefile, Taskfile.yml
- Extract commands from: npm scripts, Makefile targets, Taskfile tasks, go.mod for go commands
- Map directory structure: src/, test/, docs/, internal/, cmd/, pkg/
")
Agent #2: Linter Config Detective
Task(subagent_type: "Explore", model: "sonnet", prompt: "
Find all linter/formatter configuration files and return JSON:
[
{path: string, tool: string, ruleCount: estimate}
]
Search for:
- ESLint: .eslintrc*, eslint.config.*
- Prettier: .prettierrc*, prettier.config.*
- golangci-lint: .golangci.yml, .golangci.yaml
- Rubocop: .rubocop.yml
- Pylint: pylintrc, .pylintrc, pyproject.toml
- EditorConfig: .editorconfig
- Black: pyproject.toml
- Flake8: .flake8, setup.cfg
- rustfmt: rustfmt.toml
- checkstyle: checkstyle.xml
Use Glob: **/.{eslintrc,prettierrc,golangci,rubocop,pylintrc,flake8,editorconfig}*
Also search: **/rustfmt.toml, **/checkstyle.xml, **/pyproject.toml
For each config: extract path, tool name, estimate rule count from file size
")
Agent #3: Architectural Pattern Recognizer
Task(subagent_type: "Explore", model: "sonnet", prompt: "
Analyze code organization and identify 3-5 key architectural patterns.
Focus areas:
1. Code organization: monorepo vs modular vs flat structure
2. Testing patterns: test file locations, naming conventions (test/, _test.go, .test.js, .spec.js)
3. Error handling: error wrapping patterns, custom error types
4. API patterns: REST endpoints, GraphQL schemas, gRPC services
5. Database patterns: ORM usage (sqlx, gorm, sequelize), migration strategy
6. Dependency injection: constructor injection, interface patterns
Return structured list:
[
{pattern: 'Repository pattern', description: '...', examples: ['file:line']},
{pattern: 'Error wrapping', description: '...', examples: ['file:line']},
...
]
Provide concrete file:line references for each pattern.
")
Agent #4: Repository Context Gatherer
Task(subagent_type: "general-purpose", model: "sonnet", prompt: "
Extract repository metadata and return JSON:
{
remote: string (GitHub/GitLab/Bitbucket/self-hosted URL),
readme: {
exists: bool,
projectName: string,
description: string (first 2-3 sentences),
sections: [list of ## headers]
},
contributing: bool (CONTRIBUTING.md exists),
license: string (LICENSE file content first line),
cicd: [list of CI/CD files found]
}
Steps:
1. Run: git remote -v (to get remote URL)
2. Read README.md if exists
3. Check for CONTRIBUTING.md, CODE_OF_CONDUCT.md
4. Detect CI/CD: .github/workflows/, .gitlab-ci.yml, Jenkinsfile, .circleci/config.yml
5. Read LICENSE file
")
Why parallel? Independent analyses complete in ~30s total vs ~120s sequential.
Wait for all 4 agents to complete before proceeding to Phase 2.
Check if CLAUDE.md exists at ./CLAUDE.md
# Using Read tool, not Bash
Read file_path: "./CLAUDE.md"
If exists:
wc -c CLAUDE.md | awk '{print int($1/4)}'
^## headersexistingClaudeMd = <content>, isNew = falseIf not exists:
isNew = trueexistingClaudeMd = nullParse skill arguments (from argument string):
--template=minimal|standard|comprehensive (default: standard)Validate required asset:
${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/behavioral-guidelines-section.md--no-docs is set, but this section is emitted regardless of that flagTemplate Selection:
Each range includes the ~61-line ## Behavioral Guidelines block, present in all three templates.
Content Structure:
# CLAUDE.md
This file provides guidance to Claude Code when working with this repository.
[If --no-docs NOT set:]
## Operating Guidelines
**Read `docs/operating-guidelines.md` at the start of every session.** It
defines how to plan, verify, and iterate in this repository: plan mode,
subagent strategy, verification gates, self-improvement loop, and the
communication contract. Treat it as load-bearing context.
[Always, every template, regardless of --no-docs:]
[Insert the `## Behavioral Guidelines` section verbatim from ${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/behavioral-guidelines-section.md — the asset carries its own H2 heading. Do NOT paraphrase, reorder, renumber, or compress.]
## Repository Overview
[2-3 sentences from Agent #4 README analysis + detected tech stack from Agent #1]
Example:
"This is a [detected framework] application built with [languages]. [README description]. The project follows [key pattern from Agent #3]."
## Architecture
[3-6 bullets from Agent #3 pattern analyzer]
- [Key pattern 1: e.g., "Monorepo structure with /packages"]
- [Key pattern 2: e.g., "Repository pattern for database access"]
- [Key pattern 3: ...]
[If template != minimal:]
- Link: See docs/architecture.md for detailed design decisions
## Development Commands
[Essential commands from Agent #1 build tool analysis]
```bash
# Build
[detected command]
# Test
[detected command]
# Lint
[detected command]
# Run
[detected command]
```
## Code Quality Standards
**Linters configured** (do not duplicate rules):
[From Agent #2: for each config]
- [Tool]: See [config path] for complete rule set
[If template == comprehensive:]
**Key conventions:**
- [Convention 1 from Agent #3]
- [Convention 2 from Agent #3]
## File Locations
- **Source**: [detected from Agent #1]
- **Tests**: [detected from Agent #1]
- **Docs**: docs/
[If build tool specific:]
- **Config**: [detected from Agent #1]
[If template != minimal:]
## Documentation
- docs/architecture.md: System design and component overview
- docs/workflows.md: Development processes and git workflow
- docs/patterns.md: Code patterns and best practices
[If existingClaudeMd and custom sections found:]
[Insert preserved custom sections here]
Merge Algorithm (if !isNew):
^## )Operating Guidelines section — merge rules:
--no-docs is set: do NOT insert the section. If it already exists in the current file, leave it untouched (user may have curated it).## Behavioral Guidelines.Behavioral Guidelines section — merge rules:
--no-docs, not gated on --template.## Operating Guidelines; if that section is absent (because --no-docs suppressed it), immediately after the file title. Always before ## Repository Overview.## 1. Think Before Coding, ## 2. Simplicity First, ## 3. Surgical Changes, or ## 4. Goal-Driven Execution (hand-rolled or from an older layout), delete them and emit the single wrapped section instead. Do NOT classify them as custom sections.docs/; never compressed or reworded.New File (isNew == true):
Generate from template using agent results.
Parse flag: Check if --no-docs in arguments. If yes, skip this phase.
Validate asset templates:
${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/:
architecture-template.mdworkflows-template.mdpatterns-template.mdoperating-guidelines.mdCreate docs/ folder structure (only if missing):
# Check if docs/ exists
# If not, create: docs/architecture.md, docs/workflows.md, docs/patterns.md, docs/operating-guidelines.md
docs/architecture.md (30-50 lines):
${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/architecture-template.mddocs/workflows.md (30-50 lines):
${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/workflows-template.mddocs/patterns.md (30-50 lines):
${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/patterns-template.mddocs/operating-guidelines.md (static, ~110 lines):
${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/operating-guidelines.md./docs/operating-guidelines.md — this is a static asset, not a template; do NOT substitute placeholders or alter contentCLAUDE.md referencesCreation Rules:
docs/ if it doesn't existarchitecture.md, workflows.md, patterns.md, operating-guidelines.md) if they don't exist--force flag present)operating-guidelines.md verbatimParse additional flags:
--force: Regenerate from scratch (backup existing to CLAUDE.md.backup)--dry-run: Show preview without writing filesIf --force flag:
# Backup existing CLAUDE.md
cp CLAUDE.md CLAUDE.md.backup
# Then regenerate from scratch (ignore merge algorithm)
Validation Checks:
Token count:
wc -c CLAUDE.md | awk '{print int($1/4)}'
## Operating Guidelines: ~40 tokens## Behavioral Guidelines: ~545 tokens, verbatim, non-negotiableLinter references:
Markdown validity:
## Behavioral Guidelines hierarchy intact: H2 wrapper with exactly four ### N. <Name> children, numbered 1-4## Behavioral Guidelines block matches ${CLAUDE_PLUGIN_ROOT}/assets/gen-claude/behavioral-guidelines-section.md byte-for-byte. If it does not, re-splice from the asset — do not hand-repairLink integrity:
docs/operating-guidelines.md exists (or will be created in Phase 4) whenever CLAUDE.md contains the ## Operating Guidelines section — the section must never reference a missing file## Behavioral Guidelines block must be self-contained — no docs/ or external links — so it remains valid under --no-docsToken Overflow Handling:
Protected regions — never compress, abbreviate, reorder, renumber, or relocate:
## Behavioral Guidelines — a byte-identical copy of the plugin asset. Compressing it defeats its purpose and breaks the verbatim-integrity check.## Operating Guidelines — already only ~40 tokens.All three compression passes below operate on project-specific content only.
If token count > 2500 after generation:
First pass compression:
Second pass compression:
Last resort:
CLAUDE.md + CLAUDE-EXTENDED.md## Behavioral Guidelines stays in CLAUDE.md — it never migrates to CLAUDE-EXTENDED.mdUser Presentation:
📊 CLAUDE.md Generation Complete
Analysis Results:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Detected: [languages from Agent #1]
✅ Build tool: [tool from Agent #1] ([X] commands found)
✅ Linters: [tools from Agent #2] ([X] configs found)
✅ Patterns: [count from Agent #3] architectural patterns identified
Generated CLAUDE.md:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Length: [X] tokens ([status: ✅ under 2000 / ⚠️ 2000-2500 / ❌ over 2500])
- Fixed overhead: ~585 tokens (Operating Guidelines ~40 + Behavioral Guidelines ~545)
- Project content: [X] tokens
- Behavioral Guidelines: ✅ included (~545 tokens, verbatim from plugin asset)
- Sections: [X] ([X] standard + [X] custom preserved)
- Commands: [X] development commands
[If docs/ created:]
Created documentation:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ docs/architecture.md ([X] lines)
✅ docs/workflows.md ([X] lines)
✅ docs/patterns.md ([X] lines)
✅ docs/operating-guidelines.md ([X] lines, static)
[If existing CLAUDE.md was merged:]
ℹ️ Preserved [X] custom sections from existing CLAUDE.md
[If --force was used:]
💾 Backup saved: CLAUDE.md.backup
Dry Run Mode:
If --dry-run flag present:
User Approval: If token count > 2000 or custom sections were modified:
Use AskUserQuestion:
Question: "Generated CLAUDE.md is [X] tokens. [Status message]. Proceed with writing files?"
Options:
1. "Yes, write files"
2. "Show full preview first"
3. "Apply compression and regenerate"
4. "Cancel"
Write Files: If approved (or auto-approved if < 2000 tokens and no modifications):
./CLAUDE.mddocs/ folder if neededdocs/architecture.md, docs/workflows.md, docs/patterns.md, docs/operating-guidelines.md (if not existing)Arguments are parsed from the argument string parameter:
--force: Backup existing CLAUDE.md to CLAUDE.md.backup and regenerate from scratch--template=minimal: Generate 90-110 line CLAUDE.md (overview + commands + linter refs only)--template=standard: Generate 110-140 line CLAUDE.md (includes architecture) [DEFAULT]--template=comprehensive: Generate 140-160 line CLAUDE.md (includes patterns + examples)Each range includes the ~61-line ## Behavioral Guidelines block, which is present in all three templates.
--no-docs: Skip docs/ folder creation (only generate CLAUDE.md)--dry-run: Show preview without writing any filesParsing example:
argument = "--force --template=comprehensive --dry-run"
Split by space, check for each flag presence
Timeout (>90s per agent):
All agents fail:
No README.md:
No build tool detected:
go build, go test, go vetnpm install, npm test, npm run buildpip install -r requirements.txt, pytestcargo build, cargo test, cargo clippyNo git remote:
Still over 2500 after compression:
CLAUDE-EXTENDED.md with overflow contentCLAUDE.md: "See CLAUDE-EXTENDED.md for additional context"Phase 1 agents timeout:
Token Management:
Content Quality:
Attribution Policy:
Merging Strategy:
Agent Coordination:
Works with:
/check-claude-md-tokens: Run after generation to validate token count/commit: Commit generated files with conventional commit format/audit-codebase: Use generated CLAUDE.md as quality referenceWorkflow:
# Generate CLAUDE.md
/gen-claude
# Validate token count
/check-claude-md-tokens
# Commit if valid
/commit
Primary:
./CLAUDE.md: Project-specific guidance (90-160 lines, < 2500 tokens)Plugin assets consumed (read-only, never written to docs/):
assets/gen-claude/behavioral-guidelines-section.md: spliced verbatim into ./CLAUDE.md as the ## Behavioral Guidelines section (~61 lines, ~545 tokens)Supporting (if not existing):
docs/architecture.md: System design (30-50 lines)docs/workflows.md: Development processes (30-50 lines)docs/patterns.md: Code patterns (30-50 lines)docs/operating-guidelines.md: Workflow, verification, and self-improvement rules (~110 lines, static verbatim copy from plugin assets)Backup (if --force used):
CLAUDE.md.backup: Original CLAUDE.md before regeneration# Generate with defaults (standard template)
/gen-claude
# Force regenerate from scratch
/gen-claude --force
# Generate minimal CLAUDE.md only (no docs/)
/gen-claude --template=minimal --no-docs
# Preview without writing
/gen-claude --dry-run
# Comprehensive with docs/
/gen-claude --template=comprehensive
# Regenerate and skip docs folder
/gen-claude --force --no-docs
✅ CLAUDE.md generated or enhanced (90-160 lines)
✅ Token count < 2500 (ideally < 2000)
✅ Contains project overview (2-3 sentences)
✅ Lists development commands (4-8 commands)
✅ References linter configs (no rule duplication)
✅ Documents architectural patterns (3-6 patterns)
✅ Links to docs/ for extended info
✅ Preserves user customizations (if merging)
✅ docs/ created with 4 files — architecture, workflows, patterns, operating-guidelines (unless --no-docs)
✅ CLAUDE.md includes ## Operating Guidelines section pointing at docs/operating-guidelines.md (unless --no-docs)
✅ CLAUDE.md includes ## Behavioral Guidelines with 4 numbered subsections, byte-identical to the plugin asset (always — including --no-docs and --template=minimal)
✅ All validation checks pass
✅ Total runtime < 60 seconds (with parallel agents)
What SKILL.md sets; muted values are Claude Code's defaults
18 skills in this plugin
/analyze-and-create-issueAnalyze codebase and create GitHub/GitLab/Forgejo issues per finding/analyze-prReview PR for quality, security, and coverage (GitHub/GitLab/Forgejo)/audit-codebaseAudit security, performance, and best practices holistically/auto-mrPush current branch, create MR/PR on GitHub, GitLab, or Forgejo, wait for CI pipeline, merge, and clean up branch using auto-mr CLI/check-claude-md-tokensMonitor and optimize CLAUDE.md token count to stay under 2500 token limit/commitCreate conventional commit from staged changes with approvalnpx claudepluginhub sgaunet/claude-plugins --plugin software-engineeringOther plugins' skills for the same job