home / skills / levnikolaevich / claude-code-skills / ln-113-backend-docs-creator

ln-113-backend-docs-creator skill

/ln-113-backend-docs-creator

This skill generates backend documentation for api_spec.md and database_schema.md using project context, ensuring OpenAPI compliance and ER diagrams.

npx playbooks add skill levnikolaevich/claude-code-skills --skill ln-113-backend-docs-creator

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
4.0 KB
---
name: ln-113-backend-docs-creator
description: Creates 2 backend docs (api_spec.md, database_schema.md). L3 Worker invoked CONDITIONALLY when hasBackend or hasDatabase detected.
---

> **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)

| File | Condition | Questions | Auto-Discovery |
|------|-----------|-----------|----------------|
| docs/project/api_spec.md | hasBackend | Q39-Q40 | Medium |
| docs/project/database_schema.md | hasDatabase | Q41-Q42 | High |

## 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
```json
{
  "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

Overview

This skill creates two backend documentation files: api_spec.md and database_schema.md, and runs only when a project has a backend or a database. It consumes a context store from the project docs coordinator and produces OpenAPI-compliant API specs and Mermaid ER diagrams for the database. It is idempotent, never overwrites existing files, and marks missing information as TBD.

How this skill works

On invocation the skill reads flags and the coordinator-provided contextStore (API_TYPE, API_ENDPOINTS, AUTH_SCHEME, DATABASE_TYPE, SCHEMA_OVERVIEW, ER_DIAGRAM). It determines which documents to produce, copies the appropriate templates, fills placeholders with context values, and generates a Mermaid ER diagram when needed. After creation it runs format and content validations (OpenAPI structure, endpoint tables, ER diagram presence) and returns a creation status to the coordinator.

When to use it

  • Project discovery indicates hasBackend=true (Express, Fastify, NestJS, FastAPI detected).
  • Project discovery indicates hasDatabase=true (Postgres, MongoDB, MySQL, Prisma, Sequelize detected).
  • As part of automated docs pipeline invoked by the project docs coordinator.
  • When you need machine-readable API contracts and visual database schemas for new or existing services.
  • When you require idempotent documentation generation that integrates with project templates.

Best practices

  • Ensure the coordinator provides a complete contextStore; the skill never performs additional code scans.
  • Keep template files in references/templates so placeholders map cleanly to context keys.
  • Run this skill after migrations/models are up to date so SCHEMA_OVERVIEW and ER_DIAGRAM reflect reality.
  • Treat api_spec.md as contract-only: include request/response schemas, not implementation code.
  • Verify stack-adaptive links and examples match the detected framework and language.

Example use cases

  • Generate api_spec.md for a Node.js REST service discovered by the coordinator with JWT auth.
  • Create database_schema.md with Mermaid ER diagram after migrations are applied for a Postgres DB.
  • Add docs to a CI docs job that runs only when backend or database flags are present.
  • Populate project docs for a microservice where endpoint tables and JSON schemas are required for client teams.
  • Produce initial docs for a greenfield service using FastAPI and a Prisma-managed database.

FAQ

What triggers this skill to run?

The project docs coordinator conditionally invokes it when hasBackend or hasDatabase is true.

Will it overwrite existing docs?

No. The skill is idempotent and skips files that already exist, logging them as skipped.