Techniques for analyzing code to extract documentation.
Analyze entry points to understand feature flow.
Find main functions, controllers, or route handlers.
Trace execution flow.
Map decision branches.
Document input validation.
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.
- HTTP method
- Route path
- Path/query parameters
- Request/response schemas
- Status codes
- Schema and input types
- Resolvers
- Return types
- Field arguments
Map dependencies and integration points.
Import/require statements
package.json dependencies
External API calls
DB connections
Message queue integrations
Filesystem 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.
- interfaces, types, classes, enums
- Schema definitions, migration files, ORM models
- JSON Schema, Joi/Yup/Zod schemas, validation decorators
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.
Complex conditionals
Calculation functions
Validation rules
State machines
Domain-specific constants and algorithms
Why logic exists (business need)
When logic applies (conditions)
What logic does (transformation)
Edge cases
Impact of changes
Document error handling and recovery.
try/catch blocks, error boundaries
Custom error classes
Error codes and messages
Logging, fallbacks, retries, 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 vulnerabilities.
- JWT, sessions, OAuth, API keys
- RBAC, permission checks, ownership validation
- Encryption, hashing, sensitive data handling
- Sanitization, SQLi/XSS/CSRF prevention
Identify performance factors and optimization opportunities.
DB query patterns (N+1)
Caching strategies
Async usage
Batch processing
Resource pooling
Memory management
Algorithm complexity
Time/space complexity
DB query counts
API response times
Memory usage
Concurrency handling
Analyze test coverage.
__tests__, *.test.ts, *.spec.ts
Function coverage
integration/, e2e/
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 configuration options and their impacts.
.env files, config files, CLI args, feature flags
Default values
Valid values
Behavior impact
Config dependencies
Security implications
Map user workflows through the feature.
Identify entry points (UI, API, CLI).
Trace user actions.
Document decision points.
Map data transformations.
Identify outcomes.
Flow diagrams, procedures, decision trees, state diagrams.
Document integration with other systems.
Sync API calls, async messaging, events, batch processing, streaming.
Protocols, auth, error handling, data transforms, SLAs.
package.json, READMEs, migration guides, breaking changes docs.
.
"engines":|"peerDependencies":|requires?\s+\w+\s+version|compatible\s+with
]]>
@deprecated, TODO comments, legacy code markers.
Deprecation date, removal timeline, migration path, alternatives.
Public APIs documented.
Examples for complex features.
Error scenarios covered.
Config options explained.
Security addressed.
Cyclomatic complexity, code duplication, test coverage, doc coverage, tech debt.