Document guideline

From Synthesys-Lab/agentize · View interactive version

Document guideline is an AI agent skill from the GitHub repository Synthesys-Lab/agentize. Instructs AI agents on documentation standards for design docs, folder READMEs, source code interfaces, and test cases

How to use this skill

Skill file

Document Guideline

This skill instructs AI agents on how to maintain comprehensive documentation throughout

the development lifecycle. It defines documentation standards that are enforced via

pre-commit linting for structural requirements, while providing guidance on content

quality and workflow integration.

Documentation Philosophy

Good documentation is:

Documentation Types

This project maintains three levels of documentation:

  1. High-level design documents (docs/*) - Architecture and design decisions
  2. Folder organization (folder README.md files) - Purpose and file organization
  3. Code interface documentation (.md companions to source files) - External and internal APIs

High-Level Design Documentation

Location: docs/* directory

Purpose: Document architectural decisions, design rationale, and high-level project structure.

When to create/update:

Not enforced by linting: Creating design documents requires human judgment about

what constitutes a "high-level design" versus implementation details.

Content guidelines:

Examples of good design documents:

When NOT to create design docs:

Folder Organization Documentation

Requirement: Every folder (except hidden folders like .git) MUST have a README.md file.

Enforced by: Pre-commit linting (scripts/lint-documentation.sh)

Purpose: Document folder purpose and file organization so developers can quickly understand

the codebase structure.

When to create:

Required content:

  1. Folder purpose: What is this folder for? (1-2 sentences)
  2. File organization: What types of files are in this folder?
  3. Key files: Brief description of important files (optional)

Examples of good folder README.md:

# Skills Directory

This directory contains all Claude Code skills that define AI agent behavior.

## Organization

Each skill is in its own subdirectory with a `SKILL.md` file:
- `commit-msg/` - Skill for creating meaningful git commits
- `fork-dev-branch/` - Skill for creating development branches
- `milestone/` - Skill for incremental implementation with milestone commits

## Adding New Skills

Create a new subdirectory and add a `SKILL.md` file with frontmatter defining
the skill name and description.

Format flexibility:

Source Code Interface Documentation

Requirement: Every source code file MUST have a corresponding .md file documenting its interfaces.

File types requiring documentation (enforced by linting):

Enforced by: Pre-commit linting (scripts/lint-documentation.sh)

Naming convention: Same prefix as source file

Required sections:

1. External Interfaces (Public APIs)

Document all interfaces exposed to external callers:

2. Internal Helpers (Private APIs)

Document internal implementation details:

Example interface documentation:

# validate_target_dir.sh

Script for validating target directories before SDK initialization.

## External Interface

### Command-line usage

./validate_target_dir.sh <target_dir> <mode>


**Parameters**:
- `target_dir`: Path to directory to validate
- `mode`: Either "init" or "update"

**Exit codes**:
- 0: Validation passed
- 1: Validation failed (directory issues)
- 2: Invalid arguments

**Output**: Error messages to stderr listing validation failures

## Internal Helpers

### check_directory_exists()
Validates that the target directory exists.

### check_write_permissions()
Validates that the user has write access to the directory.

### check_conflicting_files()
Scans for files that would conflict with SDK initialization.
Returns list of conflicting file paths.

### validate_init_mode()
Specific validation for "init" mode (directory must be empty or non-existent).

### validate_update_mode()
Specific validation for "update" mode (directory must have existing SDK structure).

When implementation changes:

Test Documentation

Requirement: Every test case MUST have documentation explaining what it tests.

Enforced by: Pre-commit linting (scripts/lint-documentation.sh)

Format options:

  1. Inline comments within the test file (preferred for simple tests)
  2. Companion .md file (for complex test suites)

Required content:

Example with inline comments:

#!/bin/bash
# Test suite for documentation linting
# Tests that the linter correctly identifies missing documentation

set -e

# Test 1: Linter passes with complete documentation
# Expected: Exit code 0, no errors
test_complete_documentation() {
    # Setup: Create temporary directory with all docs present
    ...
}

# Test 2: Linter fails when folder missing README.md
# Expected: Exit code 1, error message lists folder
test_missing_folder_readme() {
    ...
}

Example with companion .md file:

For test_documentation_lint.sh, create test_documentation_lint.md:

# Documentation Linter Test Suite

Tests for `scripts/lint-documentation.sh` to verify it correctly validates
documentation completeness.

## Test Cases

### test_complete_documentation
**Purpose**: Verify linter passes when all documentation is present
**Setup**: Temporary directory with source files and corresponding .md files
**Expected**: Exit code 0, no error output

### test_missing_folder_readme
**Purpose**: Verify linter catches folders without README.md
**Setup**: Create folder without README.md
**Expected**: Exit code 1, error message listing the folder

...

Linting check:

Documentation-Code Consistency During Milestones

Design-First TDD Workflow

This project follows strict design-first test-driven development:

  1. Phase 1: Documentation - Update all relevant documentation first
  2. Phase 2: Tests - Write test cases based on documentation
  3. Phase 3: Implementation - Write code to make tests pass

Acceptable Documentation-Code Inconsistency

During milestone commits, documentation and code may be temporarily inconsistent:

Why this happens:

When it's acceptable:

When it's NOT acceptable:

Pre-commit Linting and Milestones

The documentation linter (scripts/lint-documentation.sh) runs as part of the

pre-commit hook and validates:

Bypassing the linter:

For milestone commits where documentation is complete but implementation is incomplete:

git commit --no-verify -m "milestone: ..."

The --no-verify flag bypasses all pre-commit hooks, including:

IMPORTANT: Only bypass for milestone commits on development branches. Never bypass

for final delivery commits or commits to main branch.

Milestone progression example:

Milestone 1: Documentation complete (bypass linting OK)
- All .md files created and document final interfaces
- Implementation: 0% complete
- Tests: 0/10 passed (expected, no implementation yet)
- Commit with: --no-verify

Milestone 2: Partial implementation (bypass linting OK)
- Documentation: Still accurate for final state
- Implementation: 60% complete
- Tests: 6/10 passed
- Commit with: --no-verify

Delivery: All tests pass (NO bypass)
- Documentation: Matches implementation exactly
- Implementation: 100% complete
- Tests: 10/10 passed
- Commit without: --no-verify (linter must pass)

Integration with Other Skills

This documentation guideline integrates with other project skills:

Integration with `plan-guideline` skill

When creating implementation plans, the plan-guideline skill references these

documentation standards:

Integration with `milestone` skill

The milestone skill uses these guidelines for incremental development:

Integration with `commit-msg` skill

The commit-msg skill considers documentation standards:

Summary

Enforced by linting (structural requirements):

Guided by skill (content quality):

Workflow integration:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.