agentleFS
severity1severity1/claude-code-auto-memory/skills/codebase-analyzer/SKILL.md

codebase-analyzer

Skill159 starsChanged 8 months agoMITView on GitHub

This skill should be used when the user asks to "initialize auto-memory", "create CLAUDE.md", "set up project memory", or runs the /auto-memory:init command. Analyzes codebase structure and generates CLAUDE.md files using the exact template format with AUTO-MANAGED markers.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. notque/vexjoy-agent★ 424same name
    2. sagy101/DotSkills★ 4same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository2 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 10 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    MANDATORY: All rules below must be followed exactly.

    line 12
  2. Distinctive:

    If CLAUDE.md already exists, ask the user how to handle it:

    line 20
  3. Distinctive:

    Backup: Create CLAUDE.md.backup and generate fresh

    line 22
  4. Distinctive:

    Merge: Keep manual sections, add auto-managed sections

    line 23
  5. Distinctive:

    Look for framework boundaries that warrant separate CLAUDE.md files:

    line 40
  6. Very specific:

    If network available, fetch from https://code.claude.com/docs/en/memory:

    line 56
  7. Distinctive:

    Use AskUserQuestion to confirm:

    line 63
  8. Very specific:

    Read .claude/auto-memory/config.json to determine which files to generate based on memoryFiles:

    line 70
  9. Distinctive:

    Copy template skeleton: - Use the appropriate template (CLAUDE or AGENTS) as the base structure

    line 80
  10. Distinctive:

    When both CLAUDE.md and AGENTS.md are configured, also generate redirect files:

    line 87
  11. Distinctive:

    CRITICAL: Use the EXACT marker format below.

    line 93
  12. Distinctive:

    After generating files, report:

    line 175

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Codebase Analyzer

Analyze project structure and generate CLAUDE.md files interactively.

Guidelines

MANDATORY: All rules below must be followed exactly. Violations produce incorrect CLAUDE.md content.

@../shared/references/guidelines.md

Algorithm

1. Check Existing CLAUDE.md

If CLAUDE.md already exists, ask the user how to handle it:

  • Migrate: Convert to auto-managed format (add markers)
  • Backup: Create CLAUDE.md.backup and generate fresh
  • Merge: Keep manual sections, add auto-managed sections
  • Cancel: Abort initialization

2. Scan Directory Structure

Detect frameworks and build systems:

  • package.json - Node.js/JavaScript
  • pyproject.toml, setup.py - Python
  • Cargo.toml - Rust
  • go.mod - Go
  • Makefile - Make-based builds
  • Dockerfile - Container builds

Extract build/test/lint commands from config files.

3. Identify Subtree Candidates

Look for framework boundaries that warrant separate CLAUDE.md files:

  • src/ with 10+ source files
  • lib/ directory
  • packages/* (monorepo packages)
  • apps/* (monorepo applications)

4. Detect Code Patterns

Analyze source files for conventions:

  • Naming: PascalCase, camelCase, snake_case usage
  • Imports: ES6 modules, CommonJS, ordering patterns
  • Architecture: Feature-based, layered, MVC patterns
  • Style: Indentation, quotes, semicolons

5. Fetch Memory Guidelines (Optional)

If network available, fetch from https://code.claude.com/docs/en/memory:

  • Use WebFetch tool
  • Extract relevant sections for context
  • Reference official guidelines above as primary source

6. Present Findings

Use AskUserQuestion to confirm:

  • Detected framework and commands
  • Suggested subtree locations
  • Detected patterns

7. Generate Memory Files

Read .claude/auto-memory/config.json to determine which files to generate based on memoryFiles:

memoryFiles valueFiles to generate
absent or ["CLAUDE.md"]CLAUDE.md only (full content)
["AGENTS.md"]AGENTS.md only (full content)
["CLAUDE.md", "AGENTS.md"]AGENTS.md (full content) + CLAUDE.md (redirect)

Generate full-content files using the EXACT template structure. Follow these steps precisely:

  1. Copy template skeleton - Use the appropriate template (CLAUDE or AGENTS) as the base structure
  2. Use exact marker format - See Marker Syntax section below
  3. Replace placeholders - Substitute {{PLACEHOLDER}} with detected content
  4. Include all required sections - Even if content is minimal, include the section
  5. Add MANUAL section at the end for user notes
  6. Size limits: Root 150-200 lines, Subtrees 50-75 lines

When both CLAUDE.md and AGENTS.md are configured, also generate redirect files:

  • At the root: write CLAUDE.md using CLAUDE.redirect.md.template (static pointer, no markers)
  • For each subtree that gets an AGENTS.md: write a matching CLAUDE.md redirect alongside it

Marker Syntax

CRITICAL: Use the EXACT marker format below. Do NOT use variations.

<!-- AUTO-MANAGED: section-name -->
## Section Heading

Content goes here

<!-- END AUTO-MANAGED -->

For user-editable content:

<!-- MANUAL -->
## Custom Notes

Add project-specific notes here. This section is never auto-modified.

<!-- END MANUAL -->

Common mistakes to avoid:

  • <!-- BEGIN AUTO-MANAGED: name --> - WRONG (no BEGIN prefix)
  • <!-- END AUTO-MANAGED: name --> - WRONG (no name in closing tag)
  • <!-- AUTO-MANAGED section-name --> - WRONG (missing colon)

Section Definitions

Root CLAUDE.md Sections

Generate these sections in order:

Section NameHeadingRequiredPlaceholderContent
project-description## OverviewYes{{DESCRIPTION}}Project name, tagline, key features
build-commands## Build & Development CommandsYes{{BUILD_COMMANDS}}Build, test, lint, run commands
architecture## ArchitectureYes{{ARCHITECTURE}}Directory tree, key files, data flow
conventions## Code ConventionsYes{{CONVENTIONS}}Naming, imports, formatting rules
patterns## Detected PatternsYes{{PATTERNS}}AI-detected recurring code patterns
git-insights## Git InsightsNo{{GIT_INSIGHTS}}Key commits, design decisions
best-practices## Best PracticesNo{{BEST_PRACTICES}}From official Claude Code docs

Subtree CLAUDE.md Sections

Generate these sections in order:

Section NameHeadingRequiredPlaceholderContent
module-description## PurposeYes{{DESCRIPTION}}Module purpose and responsibility
architecture## Module ArchitectureYes{{ARCHITECTURE}}Module structure, key files
conventions## Module-Specific ConventionsYes{{CONVENTIONS}}Module-specific rules
dependencies## Key DependenciesYes{{DEPENDENCIES}}Module dependencies

Templates

Reference the template files for exact structure:

CLAUDE.md Root Template

@templates/CLAUDE.root.md.template

CLAUDE.md Subtree Template

@templates/CLAUDE.subtree.md.template

AGENTS.md Root Template

@templates/AGENTS.root.md.template

AGENTS.md Subtree Template

@templates/AGENTS.subtree.md.template

CLAUDE.md Redirect Template (when both files configured)

@templates/CLAUDE.redirect.md.template

User Interactions

Use AskUserQuestion for:

  1. Existing CLAUDE.md handling (migrate/backup/merge/cancel)
  2. Subtree location confirmation
  3. Final approval before writing files

Output

After generating files, report:

  • Files created/modified
  • Sections populated
  • Any warnings or suggestions

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.