AI Coding — or Spec-Driven Development — is a recent trend that amazes as much as it scares IT engineers. We now have access to powerful models capable of writing entire applications, but jumping from “Hello World” to a production-grade enterprise system exposes a glaring bottleneck: Context.
The hardest challenge isn’t the coding itself; it’s explaining to the AI Coding Agent how to work on the task. How do you capture your style, preferences, constraints, environment, tools, and workflow?
In my previous article, How I Revamped My Portfolio Website in 5 Nights Using AI Agents, I shared how setting up explicit context was the secret to steering the AI successfully. I refused to just “vibe code” and instead relied on firm architectural guidance.
In this follow-up article, I present the exact structure I use for my AI-assisted projects. After exploring many iterations and tools, I found that the key to success is providing the AI with the right context in a brutally simple, highly maintainable way.
Note: To make it easier to adopt, I’ve created the AI Coding 5xP Template repository. This repository acts as the single source of truth for the framework, providing a ready-to-use directory structure you can use for your own projects.
Context is Everything
AI Coding Agents are amazing at parsing documentation, but they lack common sense. Put yourself in the shoes of an AI agent: you are dropped into a closed room, and you don’t know the person you are assisting. You don’t know who you are working for or for what purpose. You just have access to the code and whatever you can infer from it.
To steer the agent in the right direction, context is the fuel. It adapts the LLM to your skill level, your objective, and your expectations. But bringing context properly is a true challenge, and I know many engineers who struggle with it.
The Pitfalls of Current Solutions
I have experimented with several approaches to provide context, and each comes with its own trade-offs:
- Autocompletion & Inference: Tools like GitHub Copilot and Google Antigravity are great for getting decent work done by inferring information from your existing codebase. However, they struggle when you start a project from scratch or when you have to rigidly copy-paste instructions over and over again to keep the agent aligned.
- Interactive Scaffolding: Frameworks like Spec-kit and Conductor allow you to prepare your context by answering questions. In practice, I found these tools too verbose. They infer a lot of content from your answers that you wouldn’t necessarily write yourself, leading to dilution of the core instructions.
- Protocol Integrations: The Model Context Protocol (MCP) is a fantastic standard for extending the capacities of your coding model by securely exposing external tools. But relying purely on MCP can bloat your LLM’s context window. Once you hit 100 tools, the model loses its focus, and you end up micromanaging tool selection instead of writing code.
- Agent Skills: Dynamically loading specific skills into your LLM is amazing for quick task execution via lazy loading. However, it’s incredibly hard to generalize skills on day one. It’s often more practical to create specific rules for your current project first, and later refactor the recurring ones into standalone skills.
My Solution: The 5xP Framework
I found that the most sustainable strategy to steer an AI Coding Agent is to use flat, readable Markdown files. I organize them using what I call the 5xP Framework: Product, Platform, Process, Profile, and Principle.
Here is how to break it down. While you can customize it, the default template provides 4 files directly under a context/ directory:
- PRODUCT.md: The objective. What are we building? Who are the users? What is the business logic? This prevents the AI from over-engineering features that don’t align with the goals.
- PLATFORM.md: The technical stack. What tools, environment, frameworks, and architectural patterns are we strictly adhering to?
- PROCESS.md: The workflow. How exactly should the AI collaborate with you? What are the quality assurance standards and AI engagement rules?
- PROFILE.md (Optional but recommended): Who are you? Explaining your background, communication style, and expertise prevents the agent from making wrong assumptions.
The 5th xP is the most important: Principle. These are your Ten Commandments, and you should put this information in an AGENTS.md file at the root of your project. Acting as the master entry point for the AI, the principles sit at the top, and the file then links to the other 4xPs, explicitly instructing the agent to read them when necessary.
Rule of Thumb: Keep each file to 1 page maximum. You should not have to scroll to read the content. This forces you to be concise, avoiding information overload for both you and the LLM.
Example Project Structure
Let’s look at a fictional project — an open-source AI task manager called TaskBrain — and see how this structure is applied in practice based on the template.
The repository structure looks like this:
taskbrain/
├── src/
├── tests/
├── context/
│ ├── PLATFORM.md
│ ├── PROCESS.md
│ ├── PRODUCT.md
│ └── PROFILE.md
└── AGENTS.md
Here is exactly how you would wire the AGENTS.md file to act as the master prompt:
# Agent Guidelines
Assume the persona of an expert AI Coding Assistant dedicated to this project.
## Principles
1. Simplicity First: Keep dependencies minimal and favor straightforward, readable solutions over complex alternatives.
2. Proactive Partnership: Anticipate potential issues and challenge decisions that contradict the project's constitution.
3. Maintainable Code: Prioritize code clarity, clean architecture, and consistent formatting across the entire codebase.
4. Contextual Awareness: Adhere to the guidelines established in the context files to ensure all contributions align with them.
5. Security by Design: Identify and mitigate security issues proactively. Treat data privacy and secrets handling as fundamental requirements.
## Context Navigation
Read the following context files as needed to understand the project's core rules and guidelines.
Suggest to the user to update the context files as needed to reflect the project's current state.
- [context/PROFILE.md](context/PROFILE.md) (Who): My background, communication style, and expertise.
- [context/PRODUCT.md](context/PRODUCT.md) (What): Core objectives, target audience, and business logic.
- [context/PLATFORM.md](context/PLATFORM.md) (Where): Technology stack, infrastructure, and architectural principles.
- [context/PROCESS.md](context/PROCESS.md) (How): Workflows, AI engagement rules, and quality assurance standards.
By keeping the root AGENTS.md file short and linking to specific sub-files in a context/ directory, the AI agent can dynamically lazy-load exactly what it needs, precisely when it needs it.
Field-Tested Results
I have thoroughly tested this framework on two distinct projects: completely revamping my personal website and bootstrapping a complex new project centered on AI Agents. In both cases, the results were night and day compared to previous approaches.
The true power of this framework lies in its human-friendliness: the files are simple, focused, and I can quickly steer the model in a new direction just by tweaking a few bullet points in a Markdown file.
Furthermore, it does not bloat the LLM. By providing what essentially acts as a “table of contents” in the root AGENTS.md (similar to exposing agent skills), the model only pulls the context it needs for the task at hand. This naturally enforces a healthy rhythm: you spend 20% of your time thinking and structuring the context, allowing the AI to smoothly handle the 80% implementation burden.
Conclusion
Every expert I know keeps iterating on how to collaborate with AI Coding Agents. Many approaches are either far too verbose, drowning the LLM in noise, or far too simplistic, leading to repetitive manual prompting.
The 5xP framework is the best trade-off I have found so far: it is brutally simple, easy to maintain natively in Git, and it works across almost every LLM coding environment.
It does not take long to set up, but it forces you to think clearly about your project’s shape before you write a single line of code. And in the era of AI engineering, thinking clearly is your greatest superpower.
Ready to start? Grab the AI Coding 5xP Template on GitHub to get up and running instantly.
