"""# Context Engineering Framework
Welcome to the Context Engineering Framework (CEF), a comprehensive template for collaborating with AI coding assistants. This framework provides a systematic way to give AI the necessary context to execute complex software development tasks effectively and autonomously.
This template was originally created by Cole Medin. It has been adapted to be model-agnostic and enhanced for broader use.
Context Engineering is to prompt engineering what a full screenplay is to a sticky note.
The CEF is built on a simple but powerful idea: most AI failures are context failures. By providing a rich, structured, and multi-faceted context, we can empower AI assistants to:
- Build Complex Features: Move beyond simple snippets to end-to-end feature implementation.
- Ensure Consistency: Adhere to your project's unique coding style, patterns, and conventions.
- Self-Correct and Validate: Use built-in validation loops to test and debug its own code.
- Reduce Hallucinations: Ground the AI in the reality of your codebase and requirements.
This framework is for you if you are:
- A developer looking to reliably delegate complex coding tasks to an AI.
- A team lead aiming to standardize how your team interacts with AI assistants.
- A hobbyist who wants to build ambitious projects with the help of AI.
- Anyone who has been frustrated by the limitations of basic prompt engineering.
The CEF workflow is a clear, two-phase process: Generate and Execute.
+--------------------------------+ +--------------------------------+
| PHASE 1: GENERATE | | PHASE 2: EXECUTE |
+--------------------------------+ +--------------------------------+
| | | |
| [ You ] --> INITIAL.md | | [ You ] --> Execute PRP |
| + | | + |
| [ Project ] -> AI_GUIDELINES.md | | [ AI ] --> Reads PRP |
| + | | | |
| [ Project ] -> examples/ | | v |
| | | | [ AI ] --> Writes Code |
| v | | | |
| [ AI ] --> Generates PRP | | v |
| | | [ AI ] --> Runs Tests |
| | | | |
| | | v |
| | | [ AI ] --> Fixes Bugs |
| | | | |
| | | v |
| | | [ You ] --> Review Feature |
+--------------------------------+ +--------------------------------+
This template provides a structured, model-agnostic workflow. Here’s how to use it with any AI coding assistant.
-
Clone this template
git clone https://github.com/sensesVoid/CEF.git cd CEF -
Set up your project rules (optional - template provided)
- Edit
AI_GUIDELINES.mdto add your project-specific guidelines.
- Edit
-
Add examples (highly recommended)
- Place relevant code examples in the
examples/folder.
- Place relevant code examples in the
-
Create your initial feature request
- Edit
INITIAL.mdwith your feature requirements.
- Edit
-
Generate a comprehensive PRP (Product Requirements Prompt)
- To do this, you will provide the contents of several files to your AI assistant. Combine the following into a single prompt:
- The content of
.prompts/commands/generate-prp.md. - The content of
AI_GUIDELINES.md. - The content of
INITIAL.md. - The content of any relevant files from the
examples/folder.
- The content of
- The AI will then generate a detailed PRP file in the
PRPs/directory.
- To do this, you will provide the contents of several files to your AI assistant. Combine the following into a single prompt:
-
Execute the PRP to implement your feature
- Once the PRP is generated, you'll ask the AI to implement it. Combine the following into a single prompt:
- The content of
.prompts/commands/execute-prp.md. - The content of the newly generated PRP file (e.g.,
PRPs/your-feature-name.md).
- The content of
- The AI will then follow the plan and implement the feature.
- Once the PRP is generated, you'll ask the AI to implement it. Combine the following into a single prompt:
context-engineering-intro/
├── .prompts/
│ └── commands/
│ ├── generate-prp.md # Instructs the AI on how to generate a PRP
│ └── execute-prp.md # Instructs the AI on how to execute a PRP
├── PRPs/
│ ├── templates/
│ │ └── prp_base.md # Base template for PRPs
│ └── EXAMPLE_multi_agent_prp.md # Example of a complete PRP
├── examples/ # Your code examples (critical!)
├── AI_GUIDELINES.md # Global rules for the AI assistant
├── INITIAL.md # Template for your feature requests
├── INITIAL_EXAMPLE.md # Example feature request
└── README.md # This file
The true power of the CEF lies in its adaptability. Here are some ways to take it to the next level:
- Multi-Agent Systems: Use the
EXAMPLE_multi_agent_prp.mdas a guide to orchestrate multiple AI agents, each with its own specialized task. - Automated Workflows: Integrate the
generateandexecutesteps into a larger script to fully automate your development pipeline. - Dynamic Examples: Write scripts to automatically pull the most relevant and up-to-date examples from your production codebase into the
examples/folder. - Tool Integration: If your AI supports tool use, you can define custom tools that allow the AI to directly interact with your file system, run tests, and even commit code.
By embracing Context Engineering, you are not just prompting an AI; you are architecting a collaboration. Happy building! ""