Document Service
AWS LabsOfficialPublished by AWS Labs
- Skill
- Content generator
- Software development
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Document Service is an automated tool designed to help engineers understand and document legacy or undocumented codebases. It performs a deep-dive analysis of the project structure, application logic, and infrastructure-as-code to produce a structured report. By prioritizing source-of-truth citations and tracing end-to-end request flows, it provides a reliable reference for developers inheriting complex systems. It is specifically optimized for AWS environments and includes support for generating visual architecture diagrams.
What it does
- Analyzes codebases to generate structured technical documentation.
- Traces end-to-end request lifecycles and business logic flows.
- Extracts infrastructure-as-code details for AWS environments.
- Creates inline Mermaid diagrams and external architecture diagrams.
- Identifies discrepancies between existing documentation and actual code.
- Provides clickable source-of-truth citations for every finding.
When to use it
- When you inherit an undocumented codebase and need to understand its architecture.
- When you need to generate technical documentation for a project.
- When you need to visualize the architecture of an AWS-based system.
- When you need to identify potential failure modes or hidden dependencies in a service.
Advantages
- Ensures documentation is always grounded in the actual code.
- Reduces onboarding time for new team members.
- Provides clear, traceable links to specific files and lines.
- Highlights tribal knowledge and implicit assumptions.
- Automates the tedious process of manual documentation.
Usage examples
- “Analyze this codebase and create technical documentation.”
- The agent will scan the directory, build a file tree, analyze the logic and infrastructure, and produce a comprehensive CODEBASE_ANALYSIS.md file.
- “I inherited this service and need to understand how it works. Can you document it?”
- The agent will perform a deep-dive analysis, mapping out modules, API contracts, and data flows to help you understand the system's design.
- “Visualize the architecture of this AWS project.”
- The agent will parse your IaC files and generate an architecture diagram, linking it to the relevant components in the documentation.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/awslabs/document-service/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip document-service.zip -d .agents/skills
Documentation by AWS Labs
Document Service
Analyze codebases to produce structured technical documentation and architecture diagrams with source-of-truth citations. Every finding links back to the exact file and line it was derived from. Optimized for AWS workloads but works with any codebase.
Core Principles
Explain WHY, not just WHAT. The reader inherited this codebase and has zero context. Listing components is not enough — explain why the architecture is shaped this way. Search for code comments, TODOs, and commit messages that reveal design rationale. When no rationale exists, mark it
[RATIONALE UNKNOWN].Trace end-to-end flows. For every API endpoint or message handler, trace the complete request path from entry to response. Note every intermediate step, transformation, timeout, and failure point. This is the "if it breaks at 3am, where do I look?" analysis.
Deep-dive complex logic. Identify the most complex or domain-specific code paths (ML pipelines, business rule engines, state machines, custom algorithms). Document HOW they work at the implementation level — the algorithm, key parameters, edge cases, and where production bugs will occur. Surface-level summaries of complex code provide no value over a naive AI prompt.
Surface implicit knowledge. Look for hardcoded values, magic numbers, environment-dependent behavior, and undocumented assumptions. These are the tribal knowledge items that disappear when teams leave.
Every claim must be traceable. Include
file:linecitations for every finding. See citation-format.md. Verify citations precisely — re-read the cited file and confirm the line number is within ±3 lines. Anchor with function/variable names.Code is the source of truth. Document what actually exists in code, not what READMEs or wikis claim. Flag every discrepancy between documentation and reality.
Mark unknowns and risks explicitly. Use
[UNKNOWN]for items not inferable from code,[RISK]for unhandled failure modes,[INFERRED]for educated guesses,[RATIONALE UNKNOWN]for unexplained architecture choices. Omitting markers undermines trust.Verify quantitative claims. List directory entries programmatically and use exact counts.
Workflow
The workflow runs autonomously from Step 2 onward. Step 1 is the only interactive step.
Step 1: Gather Context
Gather from the user:
Target directory or service to analyze
Any existing documentation, design docs, or business context (accept "nothing" — this skill is designed for undocumented codebases)
If existing docs are provided, read them first to establish baseline context. If the target directory and context are already known (e.g., provided via automation or a pre-configured prompt), skip the interactive step and proceed directly to Step 2.
Check whether CODEBASE_ANALYSIS.md already exists at the output path. If so, ask the user: "Overwrite or write to a different filename?" Resolve this before proceeding — the rest of the workflow runs autonomously.
Step 2: Build File Tree and Detect Project Type
List all files recursively in the target directory
Apply exclusion patterns from exclusion-patterns.md. Also respect
.gitignore.Detect project type and framework from characteristic files. See discovery-patterns.md.
Identify entry points based on detected project type. See discovery-patterns.md.
Read the README, CLAUDE.md, or AGENTS.md if present — these contain project context.
Check git branch names (
git branch -a) for strategic context (e.g., adev/rustbranch signals a language migration in progress). Note active branches in the Architecture Overview.
Step 3: Generate Documentation Outline
Produce a hierarchical outline mapping each documentation section to specific source files:
## Documentation Outline
1. Architecture Overview → [entry points, IaC stack files] — explain WHY, not just WHAT
2. [Module A: detected name] → [source files for module A]
3. [Module B: detected name] → [source files for module B]
4. Shared Utilities → [shared/common source files]
5. Request Lifecycle → [trace end-to-end flows through the system]
6. Domain Logic Deep-Dive → [core services at implementation level: algorithms, parameters, edge cases]
7. Startup and Initialization → [boot sequence, model loading, cache warmup, dependency checks]
8. API Contracts → [route definitions, OpenAPI specs]
9. Data Models → [schema files, ORM models]
10. Deployment → [IaC files, Dockerfiles]
11. Configuration → [config files, .env.example, prompt templates, YAML configs, secrets refs]
12. Monitoring and Observability → [log groups, metrics, tracing, alarms, dashboards]
13. Security → [auth, encryption, IAM, network isolation]
14. Local Development → [how to run/test locally, CPU fallback, dev environment setup]
15. Discrepancies → (cross-reference README/metadata vs actual code)
16. Failure Modes → (cross-cutting — include detection + recovery)
17. Timeout and Dependency Chain → (map cascading timeouts across layers)Follow the section structure in technical-doc-template.md but adapt to the actual codebase — add sections for significant modules, skip sections that don't apply. Aim for balance: each section should map to a meaningful subset of files. If a module maps to more than ~30 files, consider splitting it into sub-sections.
Do NOT pause for user review. Proceed immediately to analysis.
Step 4: Analyze
Two core analysis paths:
Path A: Application Code
For each outline section, read mapped source files and extract:
API and service definitions — route handlers, controllers, gRPC services, GraphQL resolvers
Data model definitions — database schemas, ORM models, type definitions
Internal dependencies — imports between modules, shared utilities, event handlers
External integrations — SDK clients, HTTP calls, queue producers/consumers
Configuration — environment variables, feature flags, secrets references
Consult framework-patterns.md for framework-specific extraction patterns.
Path B: Infrastructure-as-Code
When IaC files are detected (CDK, CloudFormation, Terraform, Serverless Framework):
Parse resource definitions. Identify AWS resource types, relationships, and networking topology.
Map infrastructure to application components that use them.
Extract networking topology — VPCs, subnets, security groups.
Consult MCP servers — use
awsiacto confirm resource interpretations,awsknowledgefor service descriptions.
When no IaC is found, infer infrastructure from application code (SDK clients, connection strings, environment variables) and mark components as [INFERRED].
Note on CDK projects: In CDK codebases, the IaC IS application code (TypeScript/Python constructs). Process CDK files in a single pass covering both Path A and Path B rather than treating them as separate analyses. Extract both the resource definitions (Path B) and the application logic interleaved with them (Lambda bundling, environment wiring, IAM grants — Path A) simultaneously.
Writing Sections
For each outline section:
Re-read mapped source files for exact line numbers — do not rely on memory from earlier steps.
Use grep for patterns — route definitions, model declarations, error handlers.
Write content with inline citations. See citation-format.md.
Document every source file. Enumerate ALL non-generated source files. Every file should appear somewhere in the documentation — in a module table, component table, or at minimum a file inventory. Files that define symbols never imported by any execution path should be flagged as
[UNUSED]potential dead code.Analyze the test suite. Document what tests verify, what coverage gaps exist, and how to interpret test failures. Tests reveal expected behavior and edge cases.
Process cross-cutting sections (Failure Modes, Configuration, Security, Discrepancies) last, drawing on accumulated knowledge.
Discrepancy detection: After analyzing the codebase, re-read the README, CLAUDE.md, package.json description, and any project metadata. Flag every claim that does not match the actual code — features referenced but not implemented, resource types that differ, architecture components that don't exist. For legacy codebases, this "trust but verify" pass is the single most valuable output.
Actionable failure modes: For each failure mode, include the detection method (CloudWatch metric, log pattern, symptom) and recovery steps (actual commands), not just a description. The reader is an on-call engineer at 3am.
Deep Analysis Approach
Do not attempt a single-pass skim. For each module or service, use iterative deepening:
First pass — scan file structure and entry points to understand scope
Second pass — read core files, identify questions (what calls this? where is this configured? what happens on error?)
Third pass — search for answers to those questions across the codebase, trace cross-module dependencies
Write — only write the section after all three passes. Re-read cited files to verify exact line numbers.
Large Codebase Strategy
For codebases with multiple top-level modules, deep nesting, or hundreds of source files:
Primary: tracked sequential analysis. Create a
.codebase-documentor-progress.mdtask board to track progress through sections, enabling resumability if interrupted. This works on all platforms (Claude Code, Cursor, Codex, or any coding assistant).Acceleration: parallel workers. If the environment supports spawning parallel agents, assign outline sections to independent workers. Each worker reads its mapped files and produces section content with citations. Keep Architecture Overview and cross-cutting sections in the main session for assembly.
See recursive-analysis.md for detailed instructions on both approaches.
Step 5: Generate Diagrams
Two types of diagrams serve different purposes:
Sequence/flow diagrams — inline Mermaid. For request lifecycle traces and data pipeline flows identified in Step 4, generate Mermaid sequenceDiagram or flowchart blocks inline in the relevant CODEBASE_ANALYSIS.md sections. Mermaid is the community standard for simple flow diagrams and renders natively on GitHub. Keep these focused — one diagram per major request path or data flow.
Architecture diagram — always attempt the aws-architecture-diagram skill first. For the system-level architecture diagram (services, infrastructure, boundaries): invoke the aws-architecture-diagram skill (part of the deploy-on-aws plugin) with "analyze [target-directory]" to trigger Mode A. It produces a validated draw.io diagram (docs/*.drawio) with official AWS4 icons and professional styling. Only if the skill is genuinely unavailable (not installed, invocation fails), fall back to a Mermaid flowchart TD architecture overview directly in the Architecture Overview section. Include all major services, data stores, external dependencies, and infrastructure boundaries (VPC/subnets as subgraphs when IaC is present).
After diagram generation, try to export to PNG for embedding in the report. Run drawio -x -f png -b 10 -o docs/<name>.drawio.png docs/<name>.drawio. If drawio is not on PATH, skip the PNG export — the report will link to the .drawio file directly instead of embedding an image.
Cross-reference the diagram against the Architecture Overview text. Update documentation or diagram if they diverge.
Step 6: Assemble and Deliver
Assemble all sections into
CODEBASE_ANALYSIS.mdfollowing technical-doc-template.mdEmbed the architecture diagram as an image with a link to the editable source:
 > Editable source: [`docs/<name>.drawio`](./docs/<name>.drawio)If PNG export was not possible, link to the
.drawiofile directly. Mermaid flow diagrams go inline in relevant sections.When the codebase reveals clear business capabilities (API contracts, domain models, data flows, SLA configs), include a Business Context section at the end of
CODEBASE_ANALYSIS.mdfollowing business-context.md. Skip only for pure libraries or infrastructure-only code. Do NOT include speculative content — but a README describing the product IS sufficient business context.Tag items not inferable from code with
[UNKNOWN]Write
CODEBASE_ANALYSIS.mdto the target directoryRemove
.codebase-documentor-progress.mdif it was created during analysisPresent summary: components documented, APIs found, unknowns tagged, citations included
Output Files
| File | Purpose |
|---|---|
CODEBASE_ANALYSIS.md | Single output — technical docs, business context, citations, and flow diagrams |
docs/*.drawio | Architecture diagram source (editable in draw.io) |
docs/*.drawio.png | Architecture diagram image (embedded in report, if CLI export available) |
Defaults
| Setting | Default | Override |
|---|---|---|
| Primary output | CODEBASE_ANALYSIS.md | - |
| Flow diagrams | Mermaid inline (sequenceDiagram / flowchart) | "skip diagrams" |
| Architecture diagram | draw.io via aws-architecture-diagram skill (Mermaid fallback if missing) | "skip diagrams" |
| IaC reading | Read-only (never modify) | - |
| AWS enrichment | Enabled when AWS services detected | "skip AWS" |
| Scope | User-specified directory | - |
Error Handling
See error-scenarios.md for handling of empty directories, missing entry points, missing IaC, existing output files, and MCP server failures.
MCP Servers
awsknowledge
Consult when AWS services are detected. Use for enrichment (adding official service descriptions and documentation links to CODEBASE_ANALYSIS.md) and validation (confirming the analysis interpretation is correct). When the codebase is self-explanatory, validation is more valuable than enrichment — do not add MCP content just because the server is available.
Example queries: search for "Amazon ECS on EC2 GPU instances" to confirm GPU support patterns, or read the official service page for an unfamiliar AWS service to get a one-line description.
awsiac
Consult when CDK or CloudFormation files are detected. Use primarily for validation — confirm that the interpretation of a construct or resource type matches its actual behavior. Particularly useful for complex constructs with non-obvious defaults.
Example queries: confirm properties of ecs.FargateService vs ecs.Ec2Service or verify CloudFormation resource relationships. Terraform files are still analyzed by the skill itself (see discovery-patterns.md IaC Detection), just without this MCP server's schema validation.
References
Output template — CODEBASE_ANALYSIS.md section structure
Business context — Business Context section guidance (when to include, what to cover)
Citation format — Clickable citation rules and anchoring
Error scenarios — Handling common failure conditions
Exclusion patterns — Files and directories to skip during scanning
Project detection — Project type detection and entry point identification
Code extraction — Framework-specific data extraction patterns
Large codebase strategy — Tracked sequential analysis and parallel workers
Files
- ATTRIBUTION.mdAdded by AutoGineer903 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer89 B
- SKILL.md17.2 KiB
- references/business-context.md2.7 KiB
- references/citation-format.md3.7 KiB
- references/discovery-patterns.md7.8 KiB
- references/error-scenarios.md1.7 KiB
- references/exclusion-patterns.md3.9 KiB
- references/framework-patterns.md13.5 KiB
- references/recursive-analysis.md3.9 KiB
- references/technical-doc-template.md7.7 KiB
references/discovery-patterns.md
Discovery Patterns
Patterns for detecting project type, entry points, frameworks, IaC, API surface, data models, and external dependencies during codebase analysis.
Project Type Detection
Detect the project type early — it determines which entry points to look for, which frameworks to expect, and which patterns matter most.
| Indicator File(s) | Project Type | Primary Language |
|---|---|---|
package.json | Node.js | JavaScript/TypeScript |
requirements.txt, pyproject.toml, setup.py, Pipfile | Python | Python |
go.mod | Go | Go |
Cargo.toml | Rust | Rust |
pom.xml, build.gradle, build.gradle.kts | Java/Kotlin | Java/Kotlin |
*.csproj, *.sln | .NET | C# |
Gemfile | Ruby | Ruby |
mix.exs | Elixir | Elixir |
composer.json | PHP | PHP |
cdk.json (with above) | AWS CDK | (see above) |
serverless.yml | Serverless | (see above) |
.projenrc.ts, .projenrc.js | Projen | (see above) |
pnpm-workspace.yaml | pnpm monorepo | (see above) |
*.tf | Terraform | HCL |
When multiple indicators are present (e.g., package.json + requirements.txt), the project is polyglot — note all detected types and analyze each stack's entry points.
Entry Points by Project Type
| Project Type | Entry Point Files |
|---|---|
| Node.js | index.ts, index.js, app.ts, server.ts, main.ts |
| Python | main.py, app.py, manage.py, __main__.py, wsgi.py |
| Go | main.go, cmd/*/main.go |
| Rust | src/main.rs, src/lib.rs |
| Java/Kotlin | *Application.java, src/main/java/**/Main.java |
| .NET | Program.cs, Startup.cs |
| Ruby | config.ru, app.rb, bin/rails |
| PHP | index.php, public/index.php, artisan |
| Elixir | mix.exs, lib/<app>/application.ex, lib/<app>.ex |
| CDK | bin/*.ts, bin/*.py, app.py |
General Discovery Order
After detecting the project type and entry points, analyze files in this order for maximum information yield:
Package manifests (dependencies reveal the technology stack)
IaC files (infrastructure reveals the architecture)
Entry points (reveal the application structure)
Route/handler definitions (reveal API surface)
Data models and schemas (reveal domain objects)
Tests (reveal expected behavior and edge cases)
CI/CD configs (reveal deployment and build process)
README and docs (reveal intent, even if stale)
Framework Detection
| Indicator | Framework | Key Files |
|---|---|---|
package.json with express | Express.js | app.js, routes/, middleware/ |
package.json with next | Next.js | pages/, app/, next.config.* |
package.json with react | React SPA | src/App.*, src/components/ |
requirements.txt with django | Django | manage.py, settings.py, urls.py |
requirements.txt with fastapi | FastAPI | main.py, routers/, models/ |
requirements.txt with flask | Flask | app.py, routes/, templates/ |
go.mod | Go | main.go, cmd/, internal/ |
Cargo.toml | Rust | src/main.rs, src/lib.rs |
pom.xml or build.gradle | Java/Spring | src/main/java/, application.yml |
cdk.json | AWS CDK | lib/*-stack.ts, bin/*.ts |
.projenrc.ts | Projen | .projenrc.ts (full project config) |
pnpm-workspace.yaml | pnpm monorepo | packages/*/, apps/*/, extensions/* |
serverless.yml | Serverless Framework | handler.*, functions/ |
IaC Detection
| File/Pattern | IaC Type | Key Information |
|---|---|---|
cdk.json + lib/*-stack.ts | CDK TypeScript | Constructs, resources, props |
cdk.json + lib/*_stack.py | CDK Python | Constructs, resources, props |
template.yaml or template.json | CloudFormation | Resources, outputs, parameters |
*.tf files | Terraform | Resources, modules, variables |
serverless.yml | Serverless Framework | Functions, events, resources |
sam-template.yaml | AWS SAM | Functions, APIs, tables |
API Surface Detection
REST APIs
Look for route definitions:
Express:
app.get(),router.post(),app.use()FastAPI:
@app.get(),@router.post()Django:
urlpatterns,path(),re_path()Spring:
@GetMapping,@PostMapping,@RequestMappingGo:
http.HandleFunc(),mux.Handle(),gin.GET()
GraphQL
Look for schema definitions:
schema.graphql,*.graphqlfilestypeDefsin code@Query,@Mutationdecorators
Event-Driven
Look for event handlers:
SQS:
SqsEvent,sqs.receiveMessage, queue URL referencesSNS:
SnsEvent, topic ARN referencesEventBridge: rule definitions, event patterns
Kafka: consumer group configs, topic references
Data Model Detection
| Pattern | What to Extract |
|---|---|
| ORM models (Sequelize, SQLAlchemy, TypeORM, Prisma) | Entity names, fields, types, relationships |
| Migration files | Schema evolution, table structures |
| Type definitions (TypeScript interfaces, Python dataclasses) | Domain object shapes |
| JSON Schema files | Validation rules, field constraints |
| Protobuf/Avro definitions | Message formats, service contracts |
Dependency Detection
Look for external and internal dependencies:
SDK client instantiation (
new S3Client(),boto3.client('s3'))HTTP client calls to external or internal service URLs
Database connection strings and queue/topic ARN references
Environment variables referencing endpoints
Shared library imports and cross-service event publishing/subscribing
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- AWS Labs
- Publisher
- AWS Labs (Official)
- Source
- awslabs/agent-plugins · plugins/codebase-documentor-for-aws/skills/document-service · commit fbefb37
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- NOTICE (added by AutoGineer from NOTICE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by AWS Labs.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download document-service.zip