Prompt file imported from jmolz/m0lz.00 (
.windsurf/workflows/create-rules.md). Copyright stays with the author.
Create Global Rules
Analyze the codebase and generate a CLAUDE.md file with project-specific constraints and conventions.
Phase 1: Discover
Identify What Exists
Check for existing documentation:
PRD.md,.claude/PRD.md— product specREADME.md— project overviewpackage.json,pyproject.toml,Cargo.toml— dependenciestsconfig.json,vite.config.*,next.config.*— build config- Existing test files and patterns
- CI/CD workflows (
.github/workflows/) - Docker files
Identify Project Type
| Type | Indicators |
|---|---|
| Full-stack web app | Separate client/server, API routes |
| Frontend SPA | React/Vue/Svelte, no server |
| API/Backend | Express/FastAPI/etc, no frontend |
| Library/Package | exports in package.json, publishable |
| CLI Tool | bin in package.json |
| Monorepo | Multiple packages, workspaces |
Map Structure
tree -L 3 -I 'node_modules|__pycache__|.git|dist|build|.next|venv*' 2>/dev/null || find . -maxdepth 3 -type f -not -path '*/node_modules/*' -not -path '*/.git/*' | head -60
Phase 2: Analyze
Extract Patterns
From existing code, identify:
- Naming: files, functions, classes, variables
- Structure: how code is organized within files
- Errors: how errors are created and handled
- Types: how types/interfaces are defined
- Imports: relative vs absolute, named vs namespace
- Testing: framework, structure, patterns
- Logging: strategy and format
Research Best Practices
If this is a new project with a PRD but no code yet, research:
- Testing strategy for the tech stack
- Logging best practices
- Common patterns for the framework
- Component/module organization conventions
Phase 3: Generate CLAUDE.md
Write to CLAUDE.md in the project root. Keep it under 500 lines.
Use the template at .claude/templates/CLAUDE-template.md as the output structure — fill in every section with real data from the codebase analysis.
What NOT to include
- Exhaustive API documentation (put in
.claude/docs/) - Framework-specific guides (put in
.claude/rules/) - Full dependency lists (that's what package.json is for)
- Anything that isn't needed every single session
Phase 4: Create On-Demand Context (if patterns identified)
If the project has distinct subsystems, create on-demand rule files:
.claude/rules/
├── frontend.md ← component patterns, styling conventions
├── api.md ← endpoint patterns, middleware, auth
├── database.md ← query patterns, migrations, schema
└── testing.md ← mock patterns, fixtures, test utilities
Each file should have path-scoped frontmatter:
---
paths:
- "src/frontend/**"
- "src/components/**"
---
Output
Confirm:
CLAUDE.mdcreated with line count- Any
.claude/rules/files created - Any
.claude/docs/files created - What to review and customize