AgentSkillsCN

architecture-documentation

使用标准格式创建和维护架构文档

SKILL.md
--- frontmatter
name: architecture-documentation
description: Create and maintain architecture documentation using standard formats
version: "2.0.0"
sasmp_version: "1.3.0"
bonded_agent: 02-architecture-documentation
bond_type: PRIMARY_BOND
last_updated: "2025-01"

Architecture Documentation Skill

Purpose

Generate architecture documentation in standard formats including ADRs, C4 diagrams, and technical specifications with consistent structure and quality.


Parameters

ParameterTypeRequiredValidationDefault
doc_typeenumadr|c4|sequence|overview-
contextstringmin: 20 chars-
formatenummarkdown|mermaid|plantumlmarkdown
audienceenumtechnical|executive|mixedtechnical
detail_levelenumoverview|detaileddetailed

Execution Flow

code
┌──────────────────────────────────────────────────────────┐
│ 1. VALIDATE: Check doc_type and context                   │
│ 2. SELECT: Choose appropriate template                    │
│ 3. GATHER: Extract relevant information                   │
│ 4. GENERATE: Create documentation content                 │
│ 5. FORMAT: Apply output format (Mermaid, etc.)           │
│ 6. VALIDATE: Check completeness and consistency           │
│ 7. RETURN: Deliver formatted document                     │
└──────────────────────────────────────────────────────────┘

Retry Logic

ErrorRetryBackoffMax Attempts
TEMPLATE_ERRORYes1s2
VALIDATION_FAILEDNo-1
FORMAT_ERRORYes500ms3

Logging & Observability

yaml
log_points:
  - event: doc_generation_started
    level: info
    data: [doc_type, format]
  - event: doc_generation_complete
    level: info
    data: [doc_type, size_bytes, completeness_score]
  - event: validation_warning
    level: warn
    data: [missing_sections]

metrics:
  - name: docs_generated
    type: counter
    labels: [doc_type]
  - name: generation_time_ms
    type: histogram
  - name: completeness_score
    type: gauge

Error Handling

Error CodeDescriptionRecovery
E101Missing contextRequest system/decision context
E102Invalid doc_typeShow available doc types
E103Inconsistent contentFlag for review
E104Diagram syntax errorValidate and fix Mermaid/PlantUML

Unit Test Template

yaml
test_cases:
  - name: "Generate ADR"
    input:
      doc_type: "adr"
      context: "Choosing PostgreSQL for user data"
      format: "markdown"
    expected:
      contains: ["## Status", "## Decision", "## Consequences"]
      valid_markdown: true

  - name: "Generate C4 Container Diagram"
    input:
      doc_type: "c4"
      context: "E-commerce platform with React, Node.js, PostgreSQL"
      format: "mermaid"
    expected:
      contains: ["C4Container", "Container(", "Rel("]
      valid_mermaid: true

  - name: "Invalid doc_type"
    input:
      doc_type: "invalid"
    expected:
      error_code: "E102"

Troubleshooting

Common Issues

SymptomRoot CauseResolution
Incomplete ADRMissing decision contextAdd context, alternatives
Diagram won't renderSyntax errorValidate Mermaid syntax
Wrong audience levelMismatched detailAdjust detail_level param

Debug Checklist

code
□ Is doc_type supported?
□ Is context sufficient for doc type?
□ Is format appropriate for target?
□ Are all required sections present?
□ Is Mermaid/PlantUML syntax valid?

Templates

ADR Template

markdown
# ADR-{NUMBER}: {TITLE}

## Status
{Proposed | Accepted | Deprecated | Superseded}

## Context
{Problem description}

## Decision
{What was decided}

## Consequences
### Positive
- {Benefit}
### Negative
- {Trade-off}

C4 Container Template

mermaid
C4Container
    title {System Name}
    Person(user, "User")
    Container(app, "Application", "Technology")
    ContainerDb(db, "Database", "Technology")
    Rel(user, app, "Uses")
    Rel(app, db, "Reads/Writes")

Integration

ComponentTriggerData Flow
Agent 02Doc requestReceives context, returns formatted doc
Agent 01ADR triggerReceives decision for documentation

Quality Standards

  • Complete: All required sections populated
  • Consistent: Follows standard templates
  • Current: Reflects actual system state

Version History

VersionDateChanges
2.0.02025-01Production-grade: templates, tests, validation
1.0.02024-12Initial release