Ai Coding Prompt
09 Jun 2025How I Structure AI Instructions for My Codebase
As AI tools like GitHub Copilot and automated code review agents become more integrated into my development workflow, the way I instruct these tools is just as important as how I instruct human collaborators. After several iterations, I’ve settled on a structure that keeps my project’s AI guidance clear, maintainable, and always in sync with my core goals and principles.
The Core Idea: Centralize, Don’t Repeat
Instead of scattering AI instructions across multiple configuration files or repeating design principles in every tool, I use a single source of truth: AI_PROMPT.md
at the root of my repository.
Why Centralize?
- Consistency: All AI tools reference the same prompt, so there’s no risk of conflicting or outdated instructions.
- Maintainability: When my design principles or product goals change, I only need to update one place.
- Onboarding: New contributors (human or AI) can quickly find out how to “think” about my codebase.
The Structure
1. AI_PROMPT.md
This file contains a simple instruction:
For all AI-assisted code generation, refactoring, and documentation in this project, follow the guidance and requirements in:
- Design Principles
- PRODUCT_GOAL.md
Do not repeat or summarize their content here—always refer to those documents directly for the latest rules and clarifications.
When generating AI configuration or AI meta files, always include a reference to this AI_PROMPT.md for future maintainers.
2. Reference in All AI Configurations
Both my Copilot and Juni agent configuration files contain only a single line referencing the central prompt. Here’s where you’ll find them in my repo:
- Copilot config:
.github/copilot.yml
- Juni agent config:
.juni/agent-guidelines.yml
Each file contains:
instructions: |
Refer to the AI prompt in AI_PROMPT.md at the root of this repository for all guidance.
This keeps the configs clean and ensures every tool is aligned.
3. Design Principles and Product Goal
DESIGN_PRINCIPLES.md
contains all my architectural and coding standards (Hexagonal, SOLID, YAGNI, etc.).PRODUCT_GOAL.md
describes the MVP and vision for my project.
Benefits I’ve Noticed
- Less Drift: No more out-of-sync instructions between tools.
- Easier Refactoring: I can update my principles or goals without hunting through config files.
- Better AI Output: The AI is more likely to generate code that fits my standards and product vision.
- Potential for Clearer Collaboration: If I would work with others, contributors will know exactly where to look for my project philosophy.
Insights and Open Questions
- How do you keep your AI instructions in sync?
- Have you found ways to make AI-generated code even more aligned with your style?
- What pitfalls have you encountered with AI configuration drift?
I’d love to hear how other developers are structuring their AI guidance. If you have tips, feedback, or want to share your own approach, let’s connect!
Feel free to adapt this structure for your own projects, and let me know if it helps!