All skills
ailabs-393 avatar

/codebase-documenter

@7d5342d

This skill should be used when writing documentation for codebases, including README files, architecture documentation, code comments, and API documentation. Use this skill when users request help documenting their code, creating getting-started guides, explaining project structure, or making codebases more accessible to new developers. The skill provides templates, best practices, and structured approaches for creating clear, beginner-friendly documentation.

Use this Skill: https://skilld.dev/gh/ailabs-393/ai-labs-claude-skills/codebase-documenter

This session only. Nothing lands on disk.

assetstemplatesARCHITECTURE.template.md

≈3.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Architecture Overview

What This Document Covers

This document explains the high-level architecture of [Project Name], including how different components interact, key design decisions, and where to make common changes.

Target audience: Developers who need to understand the system design before making significant changes.

System Design

High-Level Architecture

[Create a simple ASCII diagram or describe components]

┌─────────────┐      ┌─────────────┐      ┌─────────────┐
│   Frontend  │─────▶│   Backend   │─────▶│  Database   │
│  (React)    │◀─────│   (Node.js) │◀─────│ (Postgres)  │
└─────────────┘      └─────────────┘      └─────────────┘
       │                    │
       │                    ▼
       │             ┌─────────────┐
       └────────────▶│  API Layer  │
                     └─────────────┘

Components:

  1. Frontend - [Explain what this component does and its responsibilities]
  2. Backend - [Explain what this component does and its responsibilities]
  3. Database - [Explain what data is stored and how it's organized]
  4. API Layer - [Explain how components communicate]

Technology Stack

Layer Technology Why We Chose It
Frontend [Technology] [Reasoning for choice]
Backend [Technology] [Reasoning for choice]
Database [Technology] [Reasoning for choice]
Hosting [Technology] [Reasoning for choice]

Directory Structure

project-root/
├── src/
│   ├── components/          # Reusable UI components
│   │   ├── common/         # Shared components (buttons, inputs, etc.)
│   │   ├── features/       # Feature-specific components
│   │   └── layout/         # Layout components (header, footer, etc.)
│   │
│   ├── pages/              # Page-level components (one per route)
│   │   ├── Home/          # Home page and related components
│   │   ├── Dashboard/     # Dashboard page and related components
│   │   └── Settings/      # Settings page and related components
│   │
│   ├── services/           # Business logic and external integrations
│   │   ├── api.js         # API client configuration
│   │   ├── auth.js        # Authentication logic
│   │   └── [feature].js   # Feature-specific business logic
│   │
│   ├── store/              # State management (Redux/Context/etc.)
│   │   ├── slices/        # State slices by feature
│   │   └── store.js       # Store configuration
│   │
│   ├── utils/              # Helper functions and utilities
│   │   ├── validation.js  # Input validation helpers
│   │   ├── formatting.js  # Data formatting utilities
│   │   └── constants.js   # App-wide constants
│   │
│   ├── hooks/              # Custom React hooks
│   │   └── use[Feature].js # Feature-specific hooks
│   │
│   ├── types/              # TypeScript type definitions
│   │   ├── models.ts      # Data model types
│   │   └── api.ts         # API request/response types
│   │
│   └── index.js            # Application entry point
│
├── tests/                  # Test files (mirrors src/ structure)
├── public/                 # Static assets
├── config/                 # Configuration files
└── [build-output]/         # Build artifacts (gitignored)

Directory Purpose and Rules

components/

Purpose: Reusable UI components that don't contain business logic.

What goes here:

  • Presentational components (buttons, cards, modals)
  • Layout components (headers, sidebars, containers)
  • Feature-specific components used in multiple places

What doesn't go here:

  • Business logic (put in services/)
  • Page-level components (put in pages/)
  • One-off components used in a single place (colocate with parent)

When to add a file: When you need a reusable component used in 2+ places.

services/

Purpose: Business logic, API calls, and external service integrations.

What goes here:

  • API client functions
  • Authentication and authorization logic
  • Data transformation and validation
  • Third-party service integrations

What doesn't go here:

  • UI components (put in components/)
  • State management (put in store/)
  • Pure utility functions (put in utils/)

When to add a file: When you need to interact with external services or implement complex business logic.

utils/

Purpose: Pure utility functions with no side effects.

What goes here:

  • Data formatting and parsing
  • Validation helpers
  • Constants and enumerations
  • Date/time utilities

What doesn't go here:

  • Functions that make API calls (put in services/)
  • Functions that depend on React (make a custom hook in hooks/)
  • Functions specific to one component (colocate with component)

When to add a file: When you have a pure function used in 3+ places.

Data Flow

[Feature Name] Flow

Explain how data flows through the system for a key feature:

User Action → Component → Service → API → Database
                ↓
            State Update
                ↓
            UI Re-render

Step-by-step:

  1. User triggers action in components/FeatureComponent.tsx

    • User clicks button, submits form, etc.
    • Component calls handleAction() function
  2. Component dispatches action to state management

    • Calls dispatch(featureAction(data))
    • State is updated optimistically
  3. Service layer processes request in services/feature.js

    • Validates input data
    • Transforms data to API format
    • Makes HTTP request to backend
  4. Backend processes request in api/feature/route.js

    • Validates authentication
    • Applies business logic
    • Updates database
  5. Response flows back through the layers

    • Backend returns success/error
    • Service layer transforms response
    • State is updated with final result
    • Component re-renders with new data

State Management

Architecture: [Describe state management approach - Redux, Context API, Zustand, etc.]

State organization:

Global State
├── auth          # User authentication state
├── user          # User profile data
├── [feature1]    # Feature-specific state
├── [feature2]    # Feature-specific state
└── ui            # UI state (modals, loading, etc.)

Data flow rules:

  • Components read state via [hooks/selectors]
  • Components update state via [dispatch/setState functions]
  • Async operations handled in [middleware/thunks/services]

Key Design Decisions

Decision 1: [Architecture Choice]

What we decided: [Describe the decision made]

Context: [Explain the situation that required this decision]

  • [Constraint or requirement 1]
  • [Constraint or requirement 2]

Why we decided this:

  • Reason 1: [Explain benefit]
  • Reason 2: [Explain benefit]
  • Reason 3: [Explain benefit]

Trade-offs:

  • ✅ Pros: [What we gained]
  • ❌ Cons: [What we sacrificed]
  • 🤔 When to reconsider: [Conditions that might make this decision obsolete]

Alternatives considered:

  • [Alternative 1]: Rejected because [reason]
  • [Alternative 2]: Rejected because [reason]

Decision 2: [Technology Choice]

What we decided: [Describe the decision made]

Context: [Explain the situation that required this decision]

Why we decided this:

  • [Reason 1]
  • [Reason 2]

Trade-offs:

  • ✅ Pros: [What we gained]
  • ❌ Cons: [What we sacrificed]

Alternatives considered:

  • [Alternative 1]: Rejected because [reason]
  • [Alternative 2]: Rejected because [reason]

Module Dependencies

Dependency Graph

pages/
  └─→ components/
        └─→ hooks/
              └─→ services/
                    └─→ utils/

store/
  └─→ services/
        └─→ utils/

Dependency rules:

  1. Lower layers can't depend on higher layers

    • ❌ services/ can't import from components/
    • ✅ components/ can import from services/
  2. Same-level imports require careful consideration

    • 🤔 Components importing other components: Usually OK
    • ⚠️ Services importing other services: Consider refactoring
  3. Avoid circular dependencies

    • Use dependency injection or event systems when needed

External Dependencies

Package Version Used For Notes
[package-name] [version] [purpose] [Important notes or alternatives]
[package-name] [version] [purpose] [Important notes or alternatives]

Extension Points

Adding a New Feature

To add a new feature to the codebase:

  1. Create feature structure:

    src/
    ├── components/features/[FeatureName]/
    ├── services/[featureName].js
    └── store/slices/[featureName]Slice.js
  2. Implement components:

    • Create UI components in components/features/[FeatureName]/
    • Follow existing component patterns
    • Use shared components from components/common/
  3. Add business logic:

    • Create service file in services/[featureName].js
    • Implement API calls and data transformations
    • Follow existing error handling patterns
  4. Set up state management:

    • Create slice in store/slices/[featureName]Slice.js
    • Define actions and reducers
    • Export selectors for components
  5. Add routes (if applicable):

    • Register new routes in routes.js
    • Create page component in pages/[FeatureName]/
  6. Add tests:

    • Mirror structure in tests/
    • Test components, services, and state

Common Modification Points

Adding a new API endpoint:

  • Backend: Create route in api/[feature]/route.js
  • Frontend: Add service function in services/[feature].js
  • Update types in types/api.ts

Adding a new database table:

  • Create migration in migrations/
  • Add model in models/[tableName].js
  • Update seed data if applicable

Adding a new component library:

  • Install package: npm install [package]
  • Create wrapper in components/common/[ComponentName]/
  • Configure theme/styling in config/theme.js

Performance Considerations

Critical Performance Paths

  1. [Path 1: e.g., Initial page load]

    • Current performance: [metrics]
    • Bottlenecks: [known issues]
    • Optimization strategy: [approach]
  2. [Path 2: e.g., Search functionality]

    • Current performance: [metrics]
    • Bottlenecks: [known issues]
    • Optimization strategy: [approach]

Caching Strategy

What we cache:

  • [Data type 1]: Cached in [location] for [duration]
  • [Data type 2]: Cached in [location] for [duration]

Cache invalidation:

  • [Trigger 1]: Clears [cache type]
  • [Trigger 2]: Clears [cache type]

Security Architecture

Authentication Flow

[Describe how users authenticate]

  1. User submits credentials
  2. Backend validates and issues [JWT/session/etc.]
  3. Token stored in [location]
  4. Subsequent requests include token

Authorization

Permission levels:

  • [Role 1]: Can [actions]
  • [Role 2]: Can [actions]
  • [Role 3]: Can [actions]

Implementation:

  • Frontend: Check permissions in [location]
  • Backend: Enforce permissions in [location]

Data Security

  • Sensitive data encrypted at rest: [Yes/No - how]
  • API communications: [HTTPS/TLS version]
  • Input validation: [Where and how]
  • XSS protection: [Strategy]
  • CSRF protection: [Strategy]

Deployment Architecture

Environments

Environment URL Purpose Auto-deploys
Development [url] Local development No
Staging [url] Testing before production Yes (main branch)
Production [url] Live application Yes (release tags)

Build Process

# Development build
[build-command-dev]

# Production build
[build-command-prod]

Build artifacts:

  • Output location: [path]
  • Artifacts: [list of generated files]

Deployment Steps

  1. [Step 1]
  2. [Step 2]
  3. [Step 3]

Monitoring and Observability

Logging

Log levels:

  • ERROR: [What gets logged]
  • WARN: [What gets logged]
  • INFO: [What gets logged]

Log destinations:

  • Development: [Console/file]
  • Production: [Service name/location]

Metrics

Key metrics tracked:

  • [Metric 1]: [What it measures]
  • [Metric 2]: [What it measures]

Monitoring tools:

  • [Tool name]: [What we monitor with it]

Troubleshooting

Common Architecture Issues

Issue: [Common problem]

  • Symptoms: [How to recognize it]
  • Cause: [Why it happens]
  • Solution: [How to fix it]

Additional Resources

  • [Link to API documentation]
  • [Link to database schema]
  • [Link to deployment guide]
  • [Link to contributing guidelines]

Questions and Feedback

If you have questions about the architecture or suggestions for improvements:

  • [Contact method]
  • [Issue tracker link]

Source: SKILL.md on GitHub

1 warning14d5 checks · Risk SAFE
  • Gen Agent Trust Hub14d

    The skill is a documentation tool providing templates for READMEs, architecture guides, and API documentation. It has an inherent attack surface for indirect prompt injection because it processes untrusted codebase content without explicit boundary markers or sanitization, potentially allowing malicious code to influence the agent's behavior during documentation generation.

  • Socket14d

    No alerts

  • Snyk14d

    Risk: LOW · No issues

  • Runlayer7mo

    9/9 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7d5342d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 11 months ago

README badge

README badge for ailabs-393/ai-labs-claude-skills/codebase-documenter