References (archive): SCAFFOLD_SKILLS_ARCHIVE_MAP.md — ProjectAnalyzer monorepo/service detection from Auto-Claude-develop analysis/analyzers.
Step 1: Identify Project Root
Locate project root by finding manifest files:
Search for package manager files:
package.json (Node.js/JavaScript/TypeScript)
requirements.txt, pyproject.toml, setup.py (Python)
go.mod (Go)
Cargo.toml (Rust)
pom.xml, build.gradle (Java/Maven/Gradle)
composer.json (PHP)
Identify project root:
- Directory containing primary package manager file
- Handle monorepos (multiple package.json files)
- Detect workspace configuration
Validate project root:
- Check for
.git directory
- Verify source code directories exist
- Ensure manifest files are parsable
Step 2: Detect Project Type
Classify project based on manifest files and directory structure:
Frontend Projects:
- Indicators: React, Vue, Angular, Svelte dependencies
- Directory:
src/components/, public/, assets/
- Frameworks: Next.js, Nuxt.js, Gatsby, Vite
Backend Projects:
- Indicators: Express, FastAPI, Django, Flask, Gin dependencies
- Directory:
routes/, controllers/, models/, api/
- Frameworks: Next.js API routes, FastAPI, Express
Fullstack Projects:
- Indicators: Both frontend and backend frameworks
- Directory: Combined frontend + backend structure
- Frameworks: Next.js, Remix, SvelteKit, Nuxt.js
Library/Package Projects:
- Indicators: No application-specific directories
- Files:
index.ts, lib/, dist/, build/
- Manifests:
library field in package.json
CLI Projects:
- Indicators:
bin field in package.json
- Files: CLI entry points, command parsers
- Dependencies: Commander, Yargs, Inquirer
Mobile Projects:
- Indicators: React Native, Flutter, Ionic dependencies
- Files:
android/, ios/, mobile/
- Frameworks: React Native, Expo, Flutter
Monorepo Projects:
- Indicators:
workspaces in package.json, pnpm-workspace.yaml
- Structure: Multiple packages in subdirectories
- Tools: Turborepo, Nx, Lerna
Microservices Projects:
- Indicators: Multiple service directories
- Files:
docker-compose.yml, service configs
- Structure: Service-based organization
Step 3: Framework Detection
Identify frameworks from manifest files and imports:
Read package.json dependencies (Node.js):
- Parse
dependencies and devDependencies
- Detect framework versions
- Categorize by type (framework, ui-library, testing, etc.)
Read requirements.txt (Python):
- Parse Python dependencies
- Detect FastAPI, Django, Flask
- Identify version constraints
Analyze imports (optional deep scan):
- Scan source files for import statements
- Detect used vs declared dependencies
- Identify framework-specific patterns
Framework Categories:
- Framework: React, Next.js, FastAPI, Express
- UI Library: Material-UI, Ant Design, Chakra UI
- State Management: Redux, Zustand, Pinia
- Testing: Jest, Vitest, Cypress, Playwright
- Build Tool: Vite, Webpack, Rollup, esbuild
- Database: Prisma, TypeORM, SQLAlchemy
- ORM: Prisma, Sequelize, Mongoose
- API: tRPC, GraphQL, REST
- Auth: NextAuth, Auth0, Clerk
- Logging: Winston, Pino, Bunyan
- Monitoring: Sentry, Datadog, New Relic
Confidence Scoring:
- 1.0: Framework listed in dependencies
- 0.8: Framework detected from imports
- 0.6: Framework inferred from structure
Step 4: File Statistics
Generate quantitative project statistics:
Count files by type:
- Use glob patterns for common extensions
- Exclude:
node_modules/, .git/, dist/, build/
- Group by language/file type
Count lines of code:
- Read source files and count lines
- Exclude empty lines and comments (optional)
- Calculate total LOC per language
Identify largest files:
- Track file sizes (line count)
- Report top 10 largest files
- Flag files > 1000 lines (violates micro-service principle)
Calculate averages:
- Average file size (lines)
- Average directory depth
- Files per directory
Language Detection:
- Map extensions to languages:
.ts, .tsx → TypeScript
.js, .jsx → JavaScript
.py → Python
.go → Go
.rs → Rust
.java → Java
.md → Markdown
.json → JSON
.yaml, .yml → YAML
Step 5: Structure Analysis
Analyze project structure and architecture:
Identify root directories:
- Classify directories by purpose:
- source:
src/, app/, lib/
- tests:
test/, __tests__/, cypress/
- config:
config/, .config/
- docs:
docs/, documentation/
- build:
dist/, build/, out/
- scripts:
scripts/, bin/
- assets:
assets/, static/, public/
Detect entry points:
- Main entry:
index.ts, main.py, app.py
- App entry:
app.ts, server.ts, app/page.tsx
- Handler:
handler.ts, lambda.ts
- CLI:
cli.ts, bin/
Detect architecture pattern:
- MVC:
models/, views/, controllers/
- Layered:
presentation/, business/, data/
- Hexagonal:
domain/, application/, infrastructure/
- Microservices: Multiple service directories
- Modular: Feature-based organization
- Flat: All files in src/
Detect module system:
- Check
package.json for "type": "module" (ESM)
- Scan for
import/export (ESM) vs require (CommonJS)
- Identify mixed module systems
Step 6: Dependency Analysis
Analyze dependency health:
Count dependencies:
- Production dependencies
- Development dependencies
- Total dependency count
Check for outdated packages (optional):
- Run
npm outdated or equivalent
- Parse output for outdated packages
- Identify major version updates (breaking changes)
Security scan (optional):
- Run
npm audit or equivalent
- Identify vulnerabilities by severity
- Flag critical security issues
Step 7: Code Quality Indicators
Detect code quality tooling:
Linting Configuration:
- Detect:
.eslintrc.json, eslint.config.js, ruff.toml
- Tool: ESLint, Ruff, Flake8, Pylint
- Run linter if configured (optional)
Formatting Configuration:
- Detect:
.prettierrc, pyproject.toml (Black/Ruff)
- Tool: Prettier, Black, Ruff
Testing Framework:
- Detect: Jest, Vitest, Pytest, Cypress
- Count test files
- Check for coverage configuration
Type Safety:
- Detect TypeScript:
tsconfig.json
- Check strict mode:
"strict": true
- Detect Python typing: mypy, pyright
Step 8: Pattern Detection
Identify common patterns and anti-patterns:
Good Practices:
- Modular component structure
- Comprehensive test coverage
- TypeScript strict mode enabled
- CI/CD configuration present
Anti-Patterns:
- Large files (> 1000 lines)
- Missing tests
- Outdated dependencies
- No linting configuration
Neutral Patterns:
- Specific architecture choices
- Framework-specific patterns
Step 9: Technical Debt Analysis
Calculate technical debt score:
Debt Indicators:
- Outdated Dependencies: Count outdated packages
- Missing Tests: Low test file ratio
- Dead Code: Unused imports/exports (optional)
- Complexity: Large files, deep nesting
- Documentation: Missing README, docs
- Security: Known vulnerabilities
- Performance: Bundle size, load time
Debt Score (0-100):
- 0-20: Excellent health
- 21-40: Good health, minor issues
- 41-60: Moderate debt, needs attention
- 61-80: High debt, refactoring recommended
- 81-100: Critical debt, major overhaul needed
Remediation Effort:
- Trivial: < 1 hour
- Minor: 1-4 hours
- Moderate: 1-3 days
- Major: 1-2 weeks
- Massive: > 2 weeks
Step 10: Generate Recommendations
Create prioritized improvement recommendations:
Categorize Recommendations:
- Security: Critical vulnerabilities, outdated auth
- Performance: Bundle optimization, lazy loading
- Maintainability: Refactor large files, add tests
- Testing: Increase coverage, add E2E tests
- Documentation: Add README, API docs
- Architecture: Improve modularity, separation of concerns
- Dependencies: Update packages, remove unused
Prioritize by Impact:
- P0: Critical security, blocking production
- P1: High impact, affects reliability
- P2: Medium impact, improves quality
- P3: Low impact, nice-to-have
Estimate Effort and Impact:
- Effort: trivial, minor, moderate, major, massive
- Impact: low, medium, high, critical
Step 11: Validate Output
Validate analysis output against schema:
Schema Validation:
- Validate against
project-analysis.schema.json
- Ensure all required fields present
- Check data types and formats
Output Metadata:
- Analyzer version
- Analysis duration (ms)
- Files analyzed count
- Files skipped count
- Errors encountered
- Target: < 30 seconds for typical projects (< 10k files)
- Optimization:
- Skip large directories:
node_modules/, .git/, dist/
- Use parallel file processing
- Cache results for incremental analysis
- Limit deep scans to essential files
- Use streaming for large file counts
Integration with Other Skills:
- rule-selector: Auto-select rules based on detected frameworks
- repo-rag: Semantic search for architectural patterns
- dependency-analyzer: Deep dependency analysis
- Progressive Disclosure: Start with manifest analysis, add deep scans if needed
- Performance First: Skip expensive operations for large projects
- Fail Gracefully: Handle missing files, parse errors
- Validate Output: Always validate against schema
- Cache Results: Store analysis output for reuse
- Incremental Updates: Re-analyze only changed files
# Analyze current project
node .claude/tools/analysis/project-analyzer/analyzer.mjs
# Analyze specific directory
node .claude/tools/analysis/project-analyzer/analyzer.mjs /path/to/project
# Output to file
node .claude/tools/analysis/project-analyzer/analyzer.mjs --output .claude/context/artifacts/project-analysis.json
Agent Invocation:
# Analyze current project
Analyze this project
# Generate comprehensive analysis
Perform full project analysis and save to artifacts
# Quick analysis (manifest only)
Quick project type detection
{
"analysis_id": "analysis-llm-rules-20250115",
"project_type": "fullstack",
"analyzed_at": "2025-01-15T10:30:00.000Z",
"project_root": "C:\\dev\\projects\\LLM-RULES",
"stats": {
"total_files": 1243,
"total_lines": 125430,
"languages": {
"JavaScript": 45230,
"TypeScript": 38120,
"Markdown": 25680,
"JSON": 12400,
"YAML": 4000
},
"file_types": {
".js": 234,
".mjs": 156,
".ts": 89,
".md": 312,
".json": 145
},
"directories": 87,
"avg_file_size_lines": 101,
"largest_files": [
{
"path": ".claude/tools/enforcement-gate.mjs",
"lines": 1520
}
]
},
"frameworks": [
{
"name": "nextjs",
"version": "14.0.0",
"category": "framework",
"confidence": 1.0,
"source": "package.json"
},
{
"name": "react",
"version": "18.2.0",
"category": "framework",
"confidence": 1.0,
"source": "package.json"
}
],
"structure": {
"root_directories": [
{
"name": ".claude",
"purpose": "config",
"file_count": 543
},
{
"name": "conductor-main",
"purpose": "source",
"file_count": 234
}
],
"entry_points": [
{
"path": "conductor-main/src/index.ts",
"type": "main"
}
],
"architecture_pattern": "modular",
"module_system": "esm"
},
"dependencies": {
"production": 45,
"development": 23
},
"code_quality": {
"linting": {
"configured": true,
"tool": "eslint"
},
"formatting": {
"configured": true,
"tool": "prettier"
},
"testing": {
"framework": "vitest",
"test_files": 89,
"coverage_configured": true
},
"type_safety": {
"typescript": true,
"strict_mode": true
}
},
"tech_debt": {
"score": 35,
"indicators": [
{
"category": "complexity",
"severity": "medium",
"description": "3 files exceed 1000 lines",
"remediation_effort": "moderate"
}
]
},
"recommendations": [
{
"priority": "P1",
"category": "maintainability",
"title": "Refactor large files",
"description": "Break down files > 1000 lines into smaller modules",
"effort": "moderate",
"impact": "high"
}
],
"metadata": {
"analyzer_version": "1.0.0",
"analysis_duration_ms": 2340,
"files_analyzed": 1243,
"files_skipped": 3420,
"errors": []
}
}
Smart Categorization Scoring (Inspired by Skill_Seekers smart_categorize)
When classifying files, directories, or components into categories, use weighted keyword scoring instead of simple string matching to prevent false positives:
| Signal Source |
Score Weight |
Example |
| File path/URL |
3 points |
/api/routes/ matches "API" category |
| File/class name |
2 points |
AuthService.ts matches "Authentication" |
| File content/imports |
1 point |
import express matches "Backend" |
Threshold: Require 2+ total points before assigning a category. Falls back to "other" if no category scores above threshold. This prevents weak single-signal matches from misclassifying components.
Category keywords (extend per project type):
- API: route, endpoint, controller, handler, middleware, api, rest, graphql
- Auth: auth, login, session, jwt, oauth, token, credential, permission
- Database: model, schema, migration, seed, repository, entity, query
- Testing: test, spec, fixture, mock, stub, e2e, integration
- Config: config, env, setting, constant, option, feature-flag
- UI: component, view, page, layout, template, style, theme
Three-Stream Analysis (Inspired by Skill_Seekers unified_codebase_analyzer)
For comprehensive project understanding, analyze three parallel streams:
Stream 1 — Code Analysis: AST patterns, framework detection, dependency graph, architecture classification. This is the existing core workflow (Steps 1-11).
Stream 2 — Documentation: README quality, API docs existence, inline doc coverage, changelog maintenance, contribution guides. Score: docFiles / totalFiles weighted by type.
Stream 3 — Community/Operations: Git activity (commit frequency, contributor count), CI/CD configuration, issue templates, PR templates, release workflow, Docker/container setup.
Combine all three streams into the output JSON under analysis.streams:
{
"streams": {
"code": { "score": 0.85, "findings": [...] },
"documentation": { "score": 0.60, "findings": [...] },
"operations": { "score": 0.75, "findings": [...] }
},
"compositeHealth": 0.73
}
Design Pattern Recognition (Inspired by Skill_Seekers C3.1 PatternRecognizer)
Detect common design patterns with confidence scoring:
| Pattern |
Detection Signal |
Confidence Threshold |
| Singleton |
Private constructor + static instance |
0.80 |
| Factory |
create* methods returning interface types |
0.70 |
| Observer |
subscribe/on/emit/addEventListener |
0.70 |
| Strategy |
Interface + multiple implementations |
0.60 |
| Decorator |
Wrapper classes with same interface |
0.60 |
| Repository |
Data access layer abstraction |
0.70 |
| Middleware |
Chain-of-responsibility in request pipeline |
0.70 |
Output detected patterns in the analysis JSON with location, confidence, and evidence:
{
"patterns": [
{
"type": "Factory",
"category": "Creational",
"confidence": 0.85,
"location": "src/services/UserFactory.ts",
"evidence": ["createUser method", "returns IUser interface"]
}
]
}
References
For additional detection patterns extracted from the Auto-Claude analysis framework, see:
references/auto-claude-patterns.md - Monorepo indicators, SERVICE_INDICATORS, SERVICE_ROOT_FILES, infrastructure detection, convention detection
references/service-patterns.md - Service type detection (frontend, backend, library), framework-specific patterns, entry point detection
references/database-patterns.md - Database configuration file patterns, ORM detection (Prisma, SQLAlchemy, TypeORM, Drizzle, Mongoose), connection string patterns
references/route-patterns.md - Express, FastAPI, Flask, Django, Next.js, Go, Rust API route detection patterns
These references provide comprehensive regex patterns and detection logic for brownfield codebase analysis.
Memory Protocol (MANDATORY)
Before starting:
Read .claude/context/memory/learnings.md
After completing:
- New pattern ->
.claude/context/memory/learnings.md
- Issue found ->
.claude/context/memory/issues.md
- Decision made ->
.claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.
1---2name: project-analyzer3description: Automated brownfield codebase analysis with weighted keyword scoring, three-stream analysis, and design pattern recognition. Detects project type, frameworks, dependencies, architecture patterns, and generates comprehensive project profile.4version: 1.1.05model: sonnet6invoked_by: both7user_invocable: true8tools: [Read, Glob, Grep, Bash]9best_practices:10 - Detect project root from package managers and manifest files11 - Identify frameworks from dependencies and directory structure12 - Generate comprehensive file statistics and language breakdown13 - Map component relationships and architecture patterns14 - Validate output against project-analysis.schema.json15 - Execute in < 30 seconds for typical projects (< 10k files)16error_handling: graceful17streaming: supported18executable: .claude/tools/analysis/project-analyzer/analyzer.mjs19test_suite: # no test file exists yet20output_schema: .claude/schemas/project-analysis.schema.json21verified: false22lastVerifiedAt: 2026-02-19T05:29:09.098Z23source: builtin24trust_score: 10025provenance_sha: 641607b45a34f39a26metadata:27 source: https://skillmd.com/skills/oimiragieo/project-analyzer28---2930**References (archive):** [SCAFFOLD_SKILLS_ARCHIVE_MAP.md](../../docs/SCAFFOLD_SKILLS_ARCHIVE_MAP.md) — ProjectAnalyzer monorepo/service detection from Auto-Claude-develop analysis/analyzers.3132<identity>33Project Analyzer - Automated brownfield codebase analysis for rapid project onboarding and understanding.34</identity>3536<capabilities>37- Detecting project type (frontend, backend, fullstack, library, cli, mobile, monorepo)38- Identifying frameworks and libraries from manifests and structure39- Generating file statistics and language breakdown40- Mapping component relationships and module structure41- Detecting architecture patterns (MVC, layered, microservices, etc.)42- Analyzing dependency health and outdated packages43- Identifying code quality indicators (linting, testing, type safety)44- Detecting technical debt and anti-patterns45- Generating prioritized improvement recommendations46</capabilities>4748<instructions>49<execution_process>5051### Step 1: Identify Project Root5253Locate project root by finding manifest files:54551. **Search for package manager files**:56 - `package.json` (Node.js/JavaScript/TypeScript)57 - `requirements.txt`, `pyproject.toml`, `setup.py` (Python)58 - `go.mod` (Go)59 - `Cargo.toml` (Rust)60 - `pom.xml`, `build.gradle` (Java/Maven/Gradle)61 - `composer.json` (PHP)62632. **Identify project root**:64 - Directory containing primary package manager file65 - Handle monorepos (multiple package.json files)66 - Detect workspace configuration67683. **Validate project root**:69 - Check for `.git` directory70 - Verify source code directories exist71 - Ensure manifest files are parsable7273### Step 2: Detect Project Type7475Classify project based on manifest files and directory structure:76771. **Frontend Projects**:78 - Indicators: React, Vue, Angular, Svelte dependencies79 - Directory: `src/components/`, `public/`, `assets/`80 - Frameworks: Next.js, Nuxt.js, Gatsby, Vite81822. **Backend Projects**:83 - Indicators: Express, FastAPI, Django, Flask, Gin dependencies84 - Directory: `routes/`, `controllers/`, `models/`, `api/`85 - Frameworks: Next.js API routes, FastAPI, Express86873. **Fullstack Projects**:88 - Indicators: Both frontend and backend frameworks89 - Directory: Combined frontend + backend structure90 - Frameworks: Next.js, Remix, SvelteKit, Nuxt.js91924. **Library/Package Projects**:93 - Indicators: No application-specific directories94 - Files: `index.ts`, `lib/`, `dist/`, `build/`95 - Manifests: `library` field in package.json96975. **CLI Projects**:98 - Indicators: `bin` field in package.json99 - Files: CLI entry points, command parsers100 - Dependencies: Commander, Yargs, Inquirer1011026. **Mobile Projects**:103 - Indicators: React Native, Flutter, Ionic dependencies104 - Files: `android/`, `ios/`, `mobile/`105 - Frameworks: React Native, Expo, Flutter1061077. **Monorepo Projects**:108 - Indicators: `workspaces` in package.json, `pnpm-workspace.yaml`109 - Structure: Multiple packages in subdirectories110 - Tools: Turborepo, Nx, Lerna1111128. **Microservices Projects**:113 - Indicators: Multiple service directories114 - Files: `docker-compose.yml`, service configs115 - Structure: Service-based organization116117### Step 3: Framework Detection118119Identify frameworks from manifest files and imports:1201211. **Read package.json dependencies** (Node.js):122 - Parse `dependencies` and `devDependencies`123 - Detect framework versions124 - Categorize by type (framework, ui-library, testing, etc.)1251262. **Read requirements.txt** (Python):127 - Parse Python dependencies128 - Detect FastAPI, Django, Flask129 - Identify version constraints1301313. **Analyze imports** (optional deep scan):132 - Scan source files for import statements133 - Detect used vs declared dependencies134 - Identify framework-specific patterns1351364. **Framework Categories**:137 - **Framework**: React, Next.js, FastAPI, Express138 - **UI Library**: Material-UI, Ant Design, Chakra UI139 - **State Management**: Redux, Zustand, Pinia140 - **Testing**: Jest, Vitest, Cypress, Playwright141 - **Build Tool**: Vite, Webpack, Rollup, esbuild142 - **Database**: Prisma, TypeORM, SQLAlchemy143 - **ORM**: Prisma, Sequelize, Mongoose144 - **API**: tRPC, GraphQL, REST145 - **Auth**: NextAuth, Auth0, Clerk146 - **Logging**: Winston, Pino, Bunyan147 - **Monitoring**: Sentry, Datadog, New Relic1481495. **Confidence Scoring**:150 - **1.0**: Framework listed in dependencies151 - **0.8**: Framework detected from imports152 - **0.6**: Framework inferred from structure153154### Step 4: File Statistics155156Generate quantitative project statistics:1571581. **Count files by type**:159 - Use glob patterns for common extensions160 - Exclude: `node_modules/`, `.git/`, `dist/`, `build/`161 - Group by language/file type1621632. **Count lines of code**:164 - Read source files and count lines165 - Exclude empty lines and comments (optional)166 - Calculate total LOC per language1671683. **Identify largest files**:169 - Track file sizes (line count)170 - Report top 10 largest files171 - Flag files > 1000 lines (violates micro-service principle)1721734. **Calculate averages**:174 - Average file size (lines)175 - Average directory depth176 - Files per directory1771785. **Language Detection**:179 - Map extensions to languages:180 - `.ts`, `.tsx` → TypeScript181 - `.js`, `.jsx` → JavaScript182 - `.py` → Python183 - `.go` → Go184 - `.rs` → Rust185 - `.java` → Java186 - `.md` → Markdown187 - `.json` → JSON188 - `.yaml`, `.yml` → YAML189190### Step 5: Structure Analysis191192Analyze project structure and architecture:1931941. **Identify root directories**:195 - Classify directories by purpose:196 - **source**: `src/`, `app/`, `lib/`197 - **tests**: `test/`, `__tests__/`, `cypress/`198 - **config**: `config/`, `.config/`199 - **docs**: `docs/`, `documentation/`200 - **build**: `dist/`, `build/`, `out/`201 - **scripts**: `scripts/`, `bin/`202 - **assets**: `assets/`, `static/`, `public/`2032042. **Detect entry points**:205 - Main entry: `index.ts`, `main.py`, `app.py`206 - App entry: `app.ts`, `server.ts`, `app/page.tsx`207 - Handler: `handler.ts`, `lambda.ts`208 - CLI: `cli.ts`, `bin/`2092103. **Detect architecture pattern**:211 - **MVC**: `models/`, `views/`, `controllers/`212 - **Layered**: `presentation/`, `business/`, `data/`213 - **Hexagonal**: `domain/`, `application/`, `infrastructure/`214 - **Microservices**: Multiple service directories215 - **Modular**: Feature-based organization216 - **Flat**: All files in src/2172184. **Detect module system**:219 - Check `package.json` for `"type": "module"` (ESM)220 - Scan for `import`/`export` (ESM) vs `require` (CommonJS)221 - Identify mixed module systems222223### Step 6: Dependency Analysis224225Analyze dependency health:2262271. **Count dependencies**:228 - Production dependencies229 - Development dependencies230 - Total dependency count2312322. **Check for outdated packages** (optional):233 - Run `npm outdated` or equivalent234 - Parse output for outdated packages235 - Identify major version updates (breaking changes)2362373. **Security scan** (optional):238 - Run `npm audit` or equivalent239 - Identify vulnerabilities by severity240 - Flag critical security issues241242### Step 7: Code Quality Indicators243244Detect code quality tooling:2452461. **Linting Configuration**:247 - Detect: `.eslintrc.json`, `eslint.config.js`, `ruff.toml`248 - Tool: ESLint, Ruff, Flake8, Pylint249 - Run linter if configured (optional)2502512. **Formatting Configuration**:252 - Detect: `.prettierrc`, `pyproject.toml` (Black/Ruff)253 - Tool: Prettier, Black, Ruff2542553. **Testing Framework**:256 - Detect: Jest, Vitest, Pytest, Cypress257 - Count test files258 - Check for coverage configuration2592604. **Type Safety**:261 - Detect TypeScript: `tsconfig.json`262 - Check strict mode: `"strict": true`263 - Detect Python typing: mypy, pyright264265### Step 8: Pattern Detection266267Identify common patterns and anti-patterns:2682691. **Good Practices**:270 - Modular component structure271 - Comprehensive test coverage272 - TypeScript strict mode enabled273 - CI/CD configuration present2742752. **Anti-Patterns**:276 - Large files (> 1000 lines)277 - Missing tests278 - Outdated dependencies279 - No linting configuration2802813. **Neutral Patterns**:282 - Specific architecture choices283 - Framework-specific patterns284285### Step 9: Technical Debt Analysis286287Calculate technical debt score:2882891. **Debt Indicators**:290 - **Outdated Dependencies**: Count outdated packages291 - **Missing Tests**: Low test file ratio292 - **Dead Code**: Unused imports/exports (optional)293 - **Complexity**: Large files, deep nesting294 - **Documentation**: Missing README, docs295 - **Security**: Known vulnerabilities296 - **Performance**: Bundle size, load time2972982. **Debt Score** (0-100):299 - 0-20: Excellent health300 - 21-40: Good health, minor issues301 - 41-60: Moderate debt, needs attention302 - 61-80: High debt, refactoring recommended303 - 81-100: Critical debt, major overhaul needed3043053. **Remediation Effort**:306 - **Trivial**: < 1 hour307 - **Minor**: 1-4 hours308 - **Moderate**: 1-3 days309 - **Major**: 1-2 weeks310 - **Massive**: > 2 weeks311312### Step 10: Generate Recommendations313314Create prioritized improvement recommendations:3153161. **Categorize Recommendations**:317 - **Security**: Critical vulnerabilities, outdated auth318 - **Performance**: Bundle optimization, lazy loading319 - **Maintainability**: Refactor large files, add tests320 - **Testing**: Increase coverage, add E2E tests321 - **Documentation**: Add README, API docs322 - **Architecture**: Improve modularity, separation of concerns323 - **Dependencies**: Update packages, remove unused3243252. **Prioritize by Impact**:326 - **P0**: Critical security, blocking production327 - **P1**: High impact, affects reliability328 - **P2**: Medium impact, improves quality329 - **P3**: Low impact, nice-to-have3303313. **Estimate Effort and Impact**:332 - Effort: trivial, minor, moderate, major, massive333 - Impact: low, medium, high, critical334335### Step 11: Validate Output336337Validate analysis output against schema:3383391. **Schema Validation**:340 - Validate against `project-analysis.schema.json`341 - Ensure all required fields present342 - Check data types and formats3433442. **Output Metadata**:345 - Analyzer version346 - Analysis duration (ms)347 - Files analyzed count348 - Files skipped count349 - Errors encountered350351</execution_process>352353<performance>354**Performance Requirements**:355356- **Target**: < 30 seconds for typical projects (< 10k files)357- **Optimization**:358 - Skip large directories: `node_modules/`, `.git/`, `dist/`359 - Use parallel file processing360 - Cache results for incremental analysis361 - Limit deep scans to essential files362 - Use streaming for large file counts363 </performance>364365<integration>366**Integration with Conductor**:367- Provides automated project discovery368- Eliminates manual context gathering369- Enables 80% faster brownfield onboarding370- Feeds project context to chat interface371372**Integration with Other Skills**:373374- **rule-selector**: Auto-select rules based on detected frameworks375- **repo-rag**: Semantic search for architectural patterns376- **dependency-analyzer**: Deep dependency analysis377 </integration>378379<best_practices>3803811. **Progressive Disclosure**: Start with manifest analysis, add deep scans if needed3822. **Performance First**: Skip expensive operations for large projects3833. **Fail Gracefully**: Handle missing files, parse errors3844. **Validate Output**: Always validate against schema3855. **Cache Results**: Store analysis output for reuse3866. **Incremental Updates**: Re-analyze only changed files387 </best_practices>388 </instructions>389390<examples>391<usage_example>392**Programmatic Usage**:393394```bash395# Analyze current project396node .claude/tools/analysis/project-analyzer/analyzer.mjs397398# Analyze specific directory399node .claude/tools/analysis/project-analyzer/analyzer.mjs /path/to/project400401# Output to file402node .claude/tools/analysis/project-analyzer/analyzer.mjs --output .claude/context/artifacts/project-analysis.json403```404405**Agent Invocation**:406407```408# Analyze current project409Analyze this project410411# Generate comprehensive analysis412Perform full project analysis and save to artifacts413414# Quick analysis (manifest only)415Quick project type detection416```417418</usage_example>419420<formatting_example>421**Sample Output** (`.claude/context/artifacts/project-analysis.json`):422423```json424{425 "analysis_id": "analysis-llm-rules-20250115",426 "project_type": "fullstack",427 "analyzed_at": "2025-01-15T10:30:00.000Z",428 "project_root": "C:\\dev\\projects\\LLM-RULES",429 "stats": {430 "total_files": 1243,431 "total_lines": 125430,432 "languages": {433 "JavaScript": 45230,434 "TypeScript": 38120,435 "Markdown": 25680,436 "JSON": 12400,437 "YAML": 4000438 },439 "file_types": {440 ".js": 234,441 ".mjs": 156,442 ".ts": 89,443 ".md": 312,444 ".json": 145445 },446 "directories": 87,447 "avg_file_size_lines": 101,448 "largest_files": [449 {450 "path": ".claude/tools/enforcement-gate.mjs",451 "lines": 1520452 }453 ]454 },455 "frameworks": [456 {457 "name": "nextjs",458 "version": "14.0.0",459 "category": "framework",460 "confidence": 1.0,461 "source": "package.json"462 },463 {464 "name": "react",465 "version": "18.2.0",466 "category": "framework",467 "confidence": 1.0,468 "source": "package.json"469 }470 ],471 "structure": {472 "root_directories": [473 {474 "name": ".claude",475 "purpose": "config",476 "file_count": 543477 },478 {479 "name": "conductor-main",480 "purpose": "source",481 "file_count": 234482 }483 ],484 "entry_points": [485 {486 "path": "conductor-main/src/index.ts",487 "type": "main"488 }489 ],490 "architecture_pattern": "modular",491 "module_system": "esm"492 },493 "dependencies": {494 "production": 45,495 "development": 23496 },497 "code_quality": {498 "linting": {499 "configured": true,500 "tool": "eslint"501 },502 "formatting": {503 "configured": true,504 "tool": "prettier"505 },506 "testing": {507 "framework": "vitest",508 "test_files": 89,509 "coverage_configured": true510 },511 "type_safety": {512 "typescript": true,513 "strict_mode": true514 }515 },516 "tech_debt": {517 "score": 35,518 "indicators": [519 {520 "category": "complexity",521 "severity": "medium",522 "description": "3 files exceed 1000 lines",523 "remediation_effort": "moderate"524 }525 ]526 },527 "recommendations": [528 {529 "priority": "P1",530 "category": "maintainability",531 "title": "Refactor large files",532 "description": "Break down files > 1000 lines into smaller modules",533 "effort": "moderate",534 "impact": "high"535 }536 ],537 "metadata": {538 "analyzer_version": "1.0.0",539 "analysis_duration_ms": 2340,540 "files_analyzed": 1243,541 "files_skipped": 3420,542 "errors": []543 }544}545```546547</formatting_example>548</examples>549550## Smart Categorization Scoring (Inspired by Skill_Seekers smart_categorize)551552When classifying files, directories, or components into categories, use weighted keyword scoring instead of simple string matching to prevent false positives:553554| Signal Source | Score Weight | Example |555| -------------------- | ------------ | ----------------------------------------- |556| File path/URL | 3 points | `/api/routes/` matches "API" category |557| File/class name | 2 points | `AuthService.ts` matches "Authentication" |558| File content/imports | 1 point | `import express` matches "Backend" |559560**Threshold**: Require 2+ total points before assigning a category. Falls back to "other" if no category scores above threshold. This prevents weak single-signal matches from misclassifying components.561562**Category keywords** (extend per project type):563564- **API**: route, endpoint, controller, handler, middleware, api, rest, graphql565- **Auth**: auth, login, session, jwt, oauth, token, credential, permission566- **Database**: model, schema, migration, seed, repository, entity, query567- **Testing**: test, spec, fixture, mock, stub, e2e, integration568- **Config**: config, env, setting, constant, option, feature-flag569- **UI**: component, view, page, layout, template, style, theme570571## Three-Stream Analysis (Inspired by Skill_Seekers unified_codebase_analyzer)572573For comprehensive project understanding, analyze three parallel streams:574575**Stream 1 — Code Analysis**: AST patterns, framework detection, dependency graph, architecture classification. This is the existing core workflow (Steps 1-11).576577**Stream 2 — Documentation**: README quality, API docs existence, inline doc coverage, changelog maintenance, contribution guides. Score: `docFiles / totalFiles` weighted by type.578579**Stream 3 — Community/Operations**: Git activity (commit frequency, contributor count), CI/CD configuration, issue templates, PR templates, release workflow, Docker/container setup.580581Combine all three streams into the output JSON under `analysis.streams`:582583```json584{585 "streams": {586 "code": { "score": 0.85, "findings": [...] },587 "documentation": { "score": 0.60, "findings": [...] },588 "operations": { "score": 0.75, "findings": [...] }589 },590 "compositeHealth": 0.73591}592```593594## Design Pattern Recognition (Inspired by Skill_Seekers C3.1 PatternRecognizer)595596Detect common design patterns with confidence scoring:597598| Pattern | Detection Signal | Confidence Threshold |599| ---------- | ------------------------------------------- | -------------------- |600| Singleton | Private constructor + static instance | 0.80 |601| Factory | `create*` methods returning interface types | 0.70 |602| Observer | `subscribe`/`on`/`emit`/`addEventListener` | 0.70 |603| Strategy | Interface + multiple implementations | 0.60 |604| Decorator | Wrapper classes with same interface | 0.60 |605| Repository | Data access layer abstraction | 0.70 |606| Middleware | Chain-of-responsibility in request pipeline | 0.70 |607608Output detected patterns in the analysis JSON with location, confidence, and evidence:609610```json611{612 "patterns": [613 {614 "type": "Factory",615 "category": "Creational",616 "confidence": 0.85,617 "location": "src/services/UserFactory.ts",618 "evidence": ["createUser method", "returns IUser interface"]619 }620 ]621}622```623624## References625626For additional detection patterns extracted from the Auto-Claude analysis framework, see:627628- `references/auto-claude-patterns.md` - Monorepo indicators, SERVICE_INDICATORS, SERVICE_ROOT_FILES, infrastructure detection, convention detection629- `references/service-patterns.md` - Service type detection (frontend, backend, library), framework-specific patterns, entry point detection630- `references/database-patterns.md` - Database configuration file patterns, ORM detection (Prisma, SQLAlchemy, TypeORM, Drizzle, Mongoose), connection string patterns631- `references/route-patterns.md` - Express, FastAPI, Flask, Django, Next.js, Go, Rust API route detection patterns632633These references provide comprehensive regex patterns and detection logic for brownfield codebase analysis.634635## Memory Protocol (MANDATORY)636637**Before starting:**638Read `.claude/context/memory/learnings.md`639640**After completing:**641642- New pattern -> `.claude/context/memory/learnings.md`643- Issue found -> `.claude/context/memory/issues.md`644- Decision made -> `.claude/context/memory/decisions.md`645646> ASSUME INTERRUPTION: If it's not in memory, it didn't happen.