← Back to Pull requests

docs: add AI coding agent guidelines #3446

Closed
unknown closed this pull request without merging on Oct 10, 2025 08:58 UTC
View on GitHub
unknown unknown commented on Oct 09, 2025 17:19 UTC
Author

What does this PR do?

Adds a comprehensive AI.md file in the repository root to guide AI coding agents working on the Testcontainers for Go codebase.

Content Overview

1. Repository Overview
- Monorepo structure (core, modules, examples, docs)
- Project organization and layout

2. Environment Setup
- Go 1.24.7 requirement and gvm usage
- Critical environment setup commands

3. Development Workflow
- Module development process
- Git conventions and commit format
- PR creation guidelines
- Testing procedures

4. Module Development Best Practices
- Container struct design (use Container, not module-specific names)
- Run function pattern (5-step implementation guide)
- Container options patterns (built-in vs custom)
- State inspection techniques with strings.CutPrefix
- Variadic arguments usage
- Return types (struct not interface)

5. Testing Guidelines
- How to run tests properly
- Test patterns to follow
- Troubleshooting common test failures

6. Common Pitfalls
- Code anti-patterns to avoid
- Git workflow mistakes
- Testing issues

7. Reference Documentation
- Pointers to detailed docs for deep dives

Why is it important?

  • Improves AI collaboration: Provides AI agents with repository-specific context and patterns

  • Reduces errors: Documents common pitfalls and best practices learned from real development

  • Speeds up onboarding: New AI agents can quickly understand the codebase structure and conventions

  • Maintains consistency: Ensures AI-generated code follows established patterns

  • Complements existing docs: Provides quick reference without duplicating detailed documentation
  • Implementation Notes

    This document distills knowledge from:

  • The module migration experience (all 49 modules migrated to Run API)

  • Best practices documented in docs/modules/index.md

  • Common patterns observed across the codebase

  • Git workflow conventions used in the repository
  • The AI.md file follows emerging industry standards for AI agent guidance, providing actionable instructions while referencing detailed documentation for deeper context.

    Alternatives

    The industry is still evolving practices for instructing AI coding agents, but several patterns are emerging:

    Current Practices

    1. .claude/ directory (Anthropic's approach)

    - .claude/commands/ - Custom slash commands
    - .claude/settings.json - Project-specific settings
    - This is what you're using now and is becoming a standard for Claude Code

    2. .github/ directory extensions

    - .github/AI_INSTRUCTIONS.md or .github/CONTRIBUTING_AI.md
    - Co-located with existing developer docs
    - Some teams add AI-specific guidelines to existing CONTRIBUTING.md

    3. Root-level files (emerging standards)

    Common names being used:
    - AI.md or AI_GUIDELINES.md - Generic instructions
    - AGENTS.md - Specifically for AI agents
    - .cursorrules - Cursor IDE specific
    - .aiderignore - Aider specific
    - CLAUDE.md - Claude-specific (less common)

    4. Inline documentation

    - docs/ai/ directory with structured guides
    - Tool-specific: docs/claude/, docs/cursor/, etc.

    What's Working Well

    Most effective patterns:

    1. Hybrid approach: Root AI.md + .claude/ for tool-specific features
    /AI.md # High-level guidelines
    /.claude/
    /commands/ # Custom commands
    /settings.json # Tool settings
    2. Content structure that works:
    - Architecture overview - "This is a Go monorepo with modules in /modules"
    - Workflow rules - "Always run tests before committing"
    - Code patterns - "Use testcontainers.Run() not GenericContainer()"
    - Anti-patterns - "Don't use interface types as return values"
    - Commit conventions - "Use conventional commits with co-author footer"
    - Testing requirements - "Run make pre-commit test before committing"
    3. Reference to existing docs - Don't duplicate, point to:
    See plan.txt for migration patterns
    See docs/modules/index.md for best practices

    Industry Momentum

    - Anthropic (Claude): .claude/ directory approach
    - Cursor: .cursorrules file
    - GitHub Copilot: Exploring .github/copilot-instructions.md
    - Aider: .aiderignore for exclusions
    - OpenAI: No official standard yet

    Related issues

  • Supports ongoing AI collaboration on the repository

  • Complements recent documentation improvements in PR #3445
  • Diff: 573 lines (+429 / -144) across 7 files Reviewer: stevenh Review duration: 938m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 573 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.380
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3446"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.8% (MEDIUM) · Higher = larger blast radius
    49.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.7% · Safe to merge
    19.7%