Get the FREE Ultimate OpenClaw Setup Guide →

ln-113-backend-docs-creator

Scanned
npx machina-cli add skill levnikolaevich/claude-code-skills/ln-113-backend-docs-creator --openclaw
Files (1)
SKILL.md
4.0 KB

Paths: File paths (shared/, references/, ../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.

Backend Documentation Creator

L3 Worker that creates 2 backend documentation files. CONDITIONAL - only invoked when project has backend or database.

Purpose & Scope

  • Creates api_spec.md (if hasBackend)
  • Creates database_schema.md (if hasDatabase)
  • Receives Context Store from ln-110-project-docs-coordinator
  • OpenAPI 3.0 compliant API specification
  • ER diagrams in Mermaid for database schema
  • Never gathers context itself; uses coordinator input

Invocation (who/when)

  • ln-110-project-docs-coordinator: CONDITIONALLY invoked when:
    • hasBackend=true (express, fastify, nestjs, fastapi detected)
    • hasDatabase=true (pg, mongoose, prisma, sequelize detected)
  • Never called directly by users

Inputs

From coordinator:

  • contextStore: Context Store with backend-specific data
    • API_TYPE (REST, GraphQL, gRPC)
    • API_ENDPOINTS (from route scan)
    • AUTH_SCHEME (JWT, OAuth2, API keys)
    • DATABASE_TYPE (PostgreSQL, MongoDB, MySQL)
    • SCHEMA_OVERVIEW (from migrations/models)
    • ER_DIAGRAM (generated from schema)
  • targetDir: Project root directory
  • flags: { hasBackend, hasDatabase }

Documents Created (2, conditional)

FileConditionQuestionsAuto-Discovery
docs/project/api_spec.mdhasBackendQ39-Q40Medium
docs/project/database_schema.mdhasDatabaseQ41-Q42High

Workflow

Phase 1: Check Conditions

  1. Parse flags from coordinator
  2. If !hasBackend && !hasDatabase: return early with empty result
  3. Determine which documents to create

Phase 2: Create Documents

For each applicable document:

  1. Check if file exists (idempotent)
  2. If exists: skip with log
  3. If not exists:
    • Copy template
    • Replace placeholders with Context Store values
    • Generate ER diagram for database_schema.md
    • Mark [TBD: X] for missing data

Phase 3: Self-Validate

  1. Check SCOPE tag
  2. Validate format:
    • api_spec.md: endpoint table, request/response examples
    • database_schema.md: ER diagram, table definitions
  3. Check Maintenance section

Phase 4: Return Status

{
  "created": ["docs/project/api_spec.md"],
  "skipped": ["docs/project/database_schema.md"],
  "tbd_count": 2,
  "validation": "OK"
}

Critical Notes

  • Conditional: Skip entirely if no backend/database detected
  • OpenAPI compliant: api_spec.md follows OpenAPI 3.0 structure
  • ER diagrams: Generated in Mermaid erDiagram format
  • Idempotent: Never overwrite existing files

NO_CODE_EXAMPLES Rule (MANDATORY)

API spec documents contracts, NOT implementations:

  • ALLOWED in api_spec.md: JSON request/response schemas (this IS the API contract), endpoint tables
  • FORBIDDEN: Controller implementations, validation classes, service code, middleware examples
  • TEMPLATE RULE: api_spec_template.md includes <!-- NO_CODE_EXAMPLES: ... --> tag - FOLLOW IT

Stack Adaptation Rule (MANDATORY)

  • Links must reference stack-appropriate docs (Microsoft for .NET, MDN for JS)
  • API examples must match project stack (Express for Node.js, FastAPI for Python)

Format Priority (MANDATORY)

Tables (endpoints, schemas) > Mermaid (ER diagrams) > Lists > Text

Definition of Done

  • Conditions checked (hasBackend, hasDatabase)
  • Applicable documents created
  • ER diagram generated (if database_schema.md created)
  • Self-validation passed
  • Actuality verified: all document facts match current code (paths, functions, APIs, configs exist and are accurate)
  • Status returned to coordinator

Reference Files

  • Templates: references/templates/api_spec_template.md, database_schema_template.md
  • Questions: references/questions_backend.md (Q39-Q42)

Version: 1.2.0 Last Updated: 2025-01-12

Source

git clone https://github.com/levnikolaevich/claude-code-skills/blob/master/ln-113-backend-docs-creator/SKILL.mdView on GitHub

Overview

ln-113-backend-docs-creator automatically produces two backend documentation files: api_spec.md (OpenAPI 3.0) and database_schema.md (Mermaid ER diagram). It runs only when the project has a backend or a database, using the Context Store from ln-110-project-docs-coordinator to fill templates.

How This Skill Works

It receives context data such as API_TYPE, API_ENDPOINTS, AUTH_SCHEME, DATABASE_TYPE, SCHEMA_OVERVIEW, and ER_DIAGRAM from the coordinator and targets the project root. It checks flags, creates files if missing (idempotent), populates templates by replacing placeholders with context values, and generates the ER diagram for database_schema.md. It reports status back to the coordinator.

When to Use It

  • When the project has a backend (REST, GraphQL, or gRPC) and you need an API spec.
  • When the project uses a database and you need a database schema diagram.
  • When documentation is coordinated by ln-110-project-docs-coordinator.
  • When you require OpenAPI 3.0 compliant API specs and Mermaid ER diagrams.
  • When you want idempotent documentation that does not overwrite existing files.

Quick Start

  1. Step 1: Ensure the project has backend or database and trigger ln-110-project-docs-coordinator with hasBackend/hasDatabase flags.
  2. Step 2: Provide contextStore (API_TYPE, API_ENDPOINTS, AUTH_SCHEME, DATABASE_TYPE, SCHEMA_OVERVIEW, ER_DIAGRAM) and targetDir to the coordinator.
  3. Step 3: Review docs at docs/project/api_spec.md and docs/project/database_schema.md; verify OpenAPI 3.0 structure and Mermaid ER diagrams.

Best Practices

  • Provide complete contextStore data (API_TYPE, API_ENDPOINTS, AUTH_SCHEME, DATABASE_TYPE, SCHEMA_OVERVIEW, ER_DIAGRAM) for accurate outputs.
  • Place generated docs under docs/project/ to match the template reference (api_spec.md and database_schema.md).
  • Ensure api_spec.md contains an endpoints table and request/response examples per the OpenAPI contract.
  • Ensure database_schema.md includes a Mermaid erDiagram and table definitions.
  • Follow the NO_CODE_EXAMPLES rule by avoiding controller/service code in the api_spec.md and mark any missing data as TBD.

Example Use Cases

  • Express REST API with PostgreSQL: generates api_spec.md with endpoints and JWT auth, and database_schema.md with a Mermaid ER diagram.
  • FastAPI service with MongoDB: produces OpenAPI spec for REST endpoints and a MongoDB ER diagram in Mermaid.
  • NestJS app using Prisma and PostgreSQL: outputs API specs for REST and a Prisma-backed schema diagram.
  • GraphQL service with PostgreSQL: api_spec.md documents GraphQL endpoints and schema, plus database_schema.md diagram.
  • Monorepo with multiple backends: coordinated docs generate two docs per backend service, maintaining consistency across projects.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers