Systematically analyze codebase structure, complexity, dependencies, and architectural patterns to understand project organization
Perform comprehensive, systematic analysis of project codebases to understand:
Auto-invoke when:
Goal: Map the high-level project organization
Tools: Glob, LS, Read
Process:
package.json, tsconfig.json, or framework-specific configsKey directories to identify:
- Source code: src/, app/, pages/, components/
- Tests: __tests__/, tests/, *.test.*, *.spec.*
- Config: config/, .config/
- Documentation: docs/, README.md
- Build output: dist/, build/, .next/
vite.config.*, webpack.config.*, next.config.*tsconfig.json, tsconfig.*.jsonpackage.json, package-lock.json, yarn.lock, pnpm-lock.yaml.env*, .env.example.gitignore, .git/Goal: Identify frameworks, libraries, and versions
Tools: Read, Grep
Process:
Read package.json:
dependencies (runtime libraries)devDependencies (development tools)scripts (available commands)engines (Node.js version requirements)Identify framework:
next in dependencies, next.config.*, app/ or pages/ directoryreact and react-domvue, *.vue filessvelte, *.svelte files@angular/core, angular.jsonIdentify key libraries:
Goal: Understand code organization and patterns
Tools: Grep, Glob, Read
Process:
Component patterns (for React/Vue/Svelte):
Use Glob to find: **/*.{jsx,tsx,vue,svelte}
Analyze:
- Component naming conventions
- File structure (co-located styles, tests)
- Component size (lines of code)
API/Backend patterns:
Use Grep to search for:
- API routes: "export.*GET|POST|PUT|DELETE"
- Database queries: "prisma\.|mongoose\.|sql"
- Authentication: "auth|jwt|session"
State management patterns:
Use Grep to find:
- Context API: "createContext|useContext"
- Redux: "createSlice|useSelector"
- Zustand: "create.*useStore"
File organization patterns:
packages/, apps/, turbo.json, nx.jsonfeatures/, modules/components/, services/, utils/, hooks/Goal: Identify potential issues and technical debt
Tools: Grep, Bash, Read
Process:
Linting & Formatting:
.eslintrc*, .prettierrc*, biome.jsonnpm run lint (via Bash)Testing coverage:
**/*.{test,spec}.{js,ts,jsx,tsx}npm run test:coverage if availableTypeScript strictness:
tsconfig.jsonstrict: true, strictNullChecks, etc.@ts-ignore or any usage (Grep)Code complexity indicators:
Use Grep to flag potential issues:
- Large files: Find files > 500 lines
- Deep nesting: Search for excessive indentation
- TODO/FIXME comments: Grep for "TODO|FIXME|HACK"
- Console logs: Grep for "console\.(log|debug|warn)"
Goal: Identify outdated or vulnerable dependencies
Tools: Bash, Read
Process:
Check for lock files:
package-lock.json, yarn.lock, pnpm-lock.yamlRun security audit (if npm/pnpm available):
npm audit --json
# or
pnpm audit --json
Check for outdated dependencies:
npm outdated
Provide a structured analysis report:
# Codebase Analysis Report
## Project Overview
- **Name**: [project name from package.json]
- **Type**: [framework/library]
- **Version**: [version]
- **Node.js**: [required version]
## Technology Stack
### Core Framework
- [Framework name & version]
### Key Dependencies
- UI: [library]
- State: [library]
- Routing: [library]
- Styling: [library]
- Testing: [library]
### Build Tools
- [Vite/Webpack/etc]
## Architecture
### Directory Structure
[tree-like representation of key directories]
### Patterns Identified
- [Component patterns]
- [State management approach]
- [API structure]
- [File organization]
## Code Quality Metrics
- **TypeScript**: [strict/loose/none]
- **Linting**: [ESLint/Biome/none]
- **Testing**: [X test files found, coverage: Y%]
- **Code Issues**: [TODOs: X, Console logs: Y]
## Recommendations
1. [Priority recommendation]
2. [Next priority]
3. ...
## Risk Areas
- [Potential issues or technical debt]
## Next Steps
- [Suggested actions based on analysis]
This skill works well with:
quality-gates - Use analysis results to run appropriate quality checksproject-initialization - Compare against templates to identify missing setuprefactoring-safe - Identify refactoring opportunitiesnextjs-optimization, react-patterns) - Auto-invoke based on detected frameworkIf analysis cannot complete:
npm install