Skip to content

Instantly share code, notes, and snippets.

@mattnico
Created July 30, 2025 19:41
Show Gist options
  • Select an option

  • Save mattnico/872eda842af2797e87d383fc77ae8757 to your computer and use it in GitHub Desktop.

Select an option

Save mattnico/872eda842af2797e87d383fc77ae8757 to your computer and use it in GitHub Desktop.
A generic prompt to build a documentation system for Claude Code or other agentic AI to reference while building. This will ensure greater consistency in architecture, naming conventions, etc.

Here's the updated prompt that removes language-specific assumptions and emphasizes documentation consultation:

Prompt for Agentic AI: Comprehensive Codebase Documentation for AI Agent Use

You are an autonomous AI agent tasked with creating comprehensive, high-utility documentation for this codebase. The primary audience for this documentation is other AI coding agents, so your output must be optimized for machine interpretation and architectural consistency across the following dimensions:

🔍 Your Objectives

  1. Discover and Map the Codebase Architecture

    • First, analyze the project structure without assumptions about programming languages, frameworks, or architectural patterns.
    • Identify and describe all major components, modules, and layers based on actual file organization and code analysis.
    • Highlight entry points, control flow, and external dependencies as they exist.
    • Document file structure, naming conventions, and build/deploy processes found in the project.
  2. Function-Level Documentation

    • For every function, method, or class discovered:
      • Provide the purpose, inputs (types and descriptions), outputs (types and descriptions), side effects, and error handling.
      • Use consistent language and formatting for AI readability.
    • Include inline comments where logical reasoning or edge case handling is present.
  3. Configuration and Environment Discovery

    • Identify all configuration files present in the project and describe:
      • The purpose of each setting or flag.
      • Dependencies and environment requirements based on actual project files and documentation.
    • Document database schemas, relationships, and initialization scripts if present.
  4. Coding Conventions and Style

    • Infer and document existing coding patterns, naming conventions, and file structures from the actual codebase.
    • Highlight any deviations or inconsistencies found.
    • Recommend appropriate style guides based on the discovered technology stack for future AI agents to follow.
  5. Key Workflows and Use Cases

    • Describe high-level flows based on code analysis (e.g., authentication, data processing, API handling).
    • Map out request/response flows for APIs and UI events as they exist in the codebase.
  6. Known Issues or Technical Debt

    • Identify undocumented patterns, legacy code, or unclear logic through code analysis.
    • Flag areas that require refactoring or pose risks to maintainability or automation.
  7. AI Agent Compatibility

    • Ensure all documentation is structured, markdown-formatted, and machine-readable (with consistent headings, semantic sections, code fences, and JSON/YAML where helpful).
    • Provide a README.md, and a /docs folder with modular files organized by feature or layer.

🧠 Analysis Approach

  • Discover before assuming: Analyze the actual codebase structure, dependencies, and patterns without preconceptions about technology stack or architecture.
  • Reference existing documentation: Always consult and reference any existing documentation, README files, or inline comments before making assumptions about functionality or intent.
  • Technology-agnostic approach: Adapt documentation structure and recommendations to the discovered technology stack and project patterns.
  • Infer intentions carefully: When documentation is missing, clearly label inferences and base them on observable code patterns and industry best practices for the discovered technologies.

⚠️ Critical Requirement Before updating, modifying, or refactoring ANY code in this project, you must:

  1. Thoroughly review all existing documentation (README files, inline comments, documentation folders, configuration comments)
  2. Consult project-specific style guides or contribution guidelines if they exist
  3. Understand the existing architecture and patterns before proposing changes
  4. Reference the documentation you create to ensure consistency with established patterns

Output Format

  • README.md: High-level overview and architecture
  • /docs/architecture.md: Component breakdown with flowcharts or diagrams (if supported)
  • /docs/functions/: One file per module or domain area with function-level documentation
  • /docs/database.md: Schema, table definitions, and relationships (if applicable)
  • /docs/configuration.md: All settings and environment setup
  • /docs/style-guide.md: Coding conventions for AI agent contribution based on discovered patterns
  • /docs/technology-stack.md: Discovered languages, frameworks, tools, and versions

Begin by analyzing the root directory structure and identifying the technology stack before making any assumptions about architecture or patterns. Prioritize discovery, accuracy, and completeness over speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment