Comprehensive techniques for analyzing code and extracting documentation-worthy
information from various aspects of a codebase.
Identify and analyze main entry points to understand feature flow
Search for main functions, controllers, or route handlers
Trace execution flow from entry to exit
Map decision branches and conditionals
Document input validation and preprocessing
main function app.listen server.start router controller handler
src/controllers/feature.controller.ts
src
(app\.(get|post|put|delete)|@(Get|Post|Put|Delete)|router\.(get|post|put|delete))
]]>
Extract API specifications from code implementations
- HTTP method
- Route path
- Path parameters
- Query parameters
- Request body schema
- Response schemas
- Status codes
- Schema types
- Resolvers
- Input types
- Return types
- Field arguments
Map all dependencies and integration points
Import statements and require calls
Package.json dependencies
External API calls
Database connections
Message queue integrations
File system operations
src
^import\s+.*from\s+['"]([^'"]+)['"]|require\s*\(\s*['"]([^'"]+)['"]\s*\)
package.json
src
(fetch|axios|http\.request|request\(|\.get\(|\.post\()
]]>
Extract data models, schemas, and type definitions
- interface definitions
- type aliases
- class declarations
- enum definitions
- Schema definitions
- Migration files
- Model definitions (ORM)
- SQL CREATE statements
- JSON Schema
- Joi/Yup schemas
- Validation decorators
- Custom validators
src
^export\s+(interface|type|class|enum)\s+(\w+)
src/models
@(Entity|Table|Model)|class\s+\w+\s+extends\s+(Model|BaseEntity)
]]>
Identify and document business rules and logic
Complex conditional statements
Calculation functions
Validation rules
State machines
Business-specific constants
Domain-specific algorithms
Why the logic exists (business requirement)
When the logic applies (conditions)
What the logic does (transformation)
Edge cases and exceptions
Business impact of changes
Document error handling strategies and recovery mechanisms
Try-catch blocks and error boundaries
Custom error classes and types
Error codes and messages
Logging strategies
Fallback mechanisms
Retry logic
Circuit breakers
src
try\s*{|catch\s*\(|throw\s+new|class\s+\w*Error\s+extends
src
ERROR_|_ERROR|ErrorCode|errorCode
]]>
Identify security measures and potential vulnerabilities
- JWT implementation
- Session management
- OAuth flows
- API key handling
- Role-based access control
- Permission checks
- Resource ownership validation
- Access control lists
- Encryption usage
- Hashing algorithms
- Sensitive data handling
- PII protection
- Input sanitization
- SQL injection prevention
- XSS protection
- CSRF tokens
Identify performance characteristics and optimization opportunities
Database query patterns (N+1 queries)
Caching strategies
Async/await usage
Batch processing
Resource pooling
Memory management
Algorithm complexity
Time complexity of algorithms
Space complexity
Database query counts
API response times
Memory usage patterns
Concurrent request handling
Analyze test coverage and quality
__tests__, *.test.ts, *.spec.ts
Function-level coverage
integration/, e2e/
Feature workflow coverage
api-tests/, *.api.test.ts
Endpoint coverage
src
\.(test|spec)\.(ts|js|tsx|jsx)$
*.test.ts
src
(describe|it|test)\s*\(\s*['"`]([^'"`]+)['"`]
]]>
Extract all configuration options and their impacts
Environment variables (.env files)
Configuration files (config.json, settings.yml)
Command-line arguments
Feature flags
Build-time constants
Default values
Valid value ranges
Impact on behavior
Dependencies between configs
Security implications
Map complete user workflows through the feature
Identify user entry points (UI, API, CLI)
Trace user actions through the system
Document decision points and branches
Map data transformations at each step
Identify exit points and outcomes
User flow diagrams
Step-by-step procedures
Decision trees
State transition diagrams
Document how the feature integrates with other systems
Synchronous API calls
Asynchronous messaging
Event-driven interactions
Batch processing
Real-time streaming
Integration protocols and formats
Authentication mechanisms
Error handling and retries
Data transformation requirements
SLA and performance expectations
Package.json engines field
README compatibility sections
Migration guides
Breaking change documentation
.
"engines":|"peerDependencies":|requires?\s+\w+\s+version|compatible\s+with
]]>
@deprecated annotations
TODO: deprecate comments
Legacy code markers
Migration warnings
Deprecation date
Removal timeline
Migration path
Alternative solutions
All public APIs documented
Examples provided for complex features
Error scenarios covered
Configuration options explained
Security considerations addressed
Cyclomatic complexity
Code duplication
Test coverage percentage
Documentation coverage
Technical debt indicators