π Language: English | ηΉι«δΈζ
A comprehensive template for getting started with Context Engineering - the discipline of engineering context for AI coding assistants so they have the information necessary to get the job done end to end.
Context Engineering is 10x better than prompt engineering and 100x better than vibe coding.
# 1. Clone this template
git clone https://github.com/google-gemini/context-engineering-gemini.git
cd context-engineering-gemini
# 2. Install dependencies (Gemini CLI)
# Refer to the original project for installation: https://github.com/google-gemini/gemini-cli
# 3. Create your initial feature request
cp INITIAL.md request.md
# ... then edit request.md with your feature requirements
# 4. Start Gemini CLI
gemini
# 5. Generate a comprehensive PRP (Product Requirements Prompt)
# In Gemini CLI, run:
/PRP:generate-prp request.md
# 6. Execute the PRP to implement your feature
# In Gemini CLI, run:
/PRP:execute-prp PRPs/request_prp.mdContext Engineering represents a paradigm shift from traditional prompt engineering:
Prompt Engineering:
-
Focuses on clever wording and specific phrasing
-
Limited to how you phrase a task
-
Like giving someone a sticky note
Context Engineering:
-
A complete system for providing comprehensive context
-
Includes documentation, examples, rules, patterns, and validation
-
Like writing a full screenplay with all the details
-
Reduces AI Failures: Most agent failures aren't model failures - they're context failures
-
Ensures Consistency: AI follows your project patterns and conventions
-
Enables Complex Features: AI can handle multi-step implementations with proper context
-
Self-Correcting: Validation loops allow AI to fix its own mistakes
context-engineering-gemini/
β
βββ .gemini/ # Houses all AI-related tooling and templates.
β βββ commands/
β β βββ PRP/
β β βββ execute-prp.toml
β β βββ generate-prp.toml
β βββ templates/
β βββ prp_template.md
β
βββ PRPs/ # Stores the detailed PRP blueprints generated by the AI.
β βββ weather_cli_prp.md
β βββ ...
β
βββ examples/ # Your code examples for the AI to follow.
β
βββ src/ # Your application's source code lives here.
β βββ weather/ # Python Example
β β βββ api.py
β β βββ cli.py
β βββ linkchecker/ # Go Example
β βββ main.go
β βββ parser.go
β βββ validator.go
β
βββ tests/ # Unit tests for your source code.
β βββ test_weather.py
β βββ linkchecker_test.go
β
βββ .gitignore
βββ GEMINI.md # Global rules and principles for the AI assistant.
βββ INITIAL.md # A blank template for writing new feature requests.
βββ INITIAL_EXAMPLE.md # An example of a completed feature request.
βββ README.md # This file.
Future Directions:
This template provides a robust foundation for Context Engineering. The next evolution of this workflow could involve integrating more advanced AI techniques, such as Retrieval-Augmented Generation (RAG) for automated documentation research and AI-driven tools (function calling) for a fully autonomous implementation and testing loop.
This framework uses a powerful, two-step workflow to build software with Gemini.
The GEMINI.md file contains project-wide rules that the AI assistant will follow. This is where you define your architectural principles, coding standards, and testing requirements to ensure consistency. You can use the provided template or customize it for your project.
To start a new feature, you don't edit the INITIAL.md template directly. Instead:
- Copy
INITIAL.mdto a new file namedrequest.md. - Fill out
request.mdwith the details of your new feature. See the "Writing Effective INITIAL.md Files" section below for tips.
First, launch the Gemini CLI in your terminal:
geminiNow, run the generate-prp command. This command sends your feature request to Gemini and asks it to act as a senior engineer, creating a detailed technical blueprint called a Product Requirements Prompt (PRP).
/PRP:generate-prp request.mdThis will create a new, permanent PRP file inside the PRPs/ directory.
Note: The
/PRP:generate-prpand/PRP:execute-prpcommands are custom commands defined in the.gemini/commands/PRP/directory. You can inspect and modify them to fit your workflow.
This is where the magic happens. Run the execute-prp command with the path to the newly created PRP.
/PRP:execute-prp PRPs/request_prp.mdThis command acts as an AI agent:
- It sends the detailed PRP to Gemini to get a step-by-step implementation plan.
- It parses the AI's response, identifying shell commands to run and code files to create.
- It then executes this plan step-by-step, pausing to ask for your confirmation before running any command or writing any file.
This allows you to sit back and supervise as the AI builds the entire feature for you, right in your local terminal.
The INITIAL.md file is the starting point for any new feature. The quality of your input here directly impacts the quality of the AI's output. Hereβs how to make it effective:
-
π― The Goal: Be specific and clear. Instead of "make a login page," write "create a login page with email/password fields, a 'Forgot Password' link, and Google OAuth integration." The more detail, the better.
-
π¨ Inspiration & Examples: This is one of the most powerful sections. If you have an existing file that shows how you handle API clients, database connections, or error handling, reference it here. It gives the AI a concrete pattern to follow, ensuring consistency.
-
π Required Knowledge: Don't make the AI guess. Provide direct links to the exact API documentation, libraries, or Stack Overflow threads it will need. This saves time and prevents the AI from using outdated or incorrect information.
-
β οΈ Potential Pitfalls & Gotchas: Think about what might go wrong. Does the API have a weird rate limit? Is there a tricky authentication flow? Mentioning these upfront helps the AI avoid common mistakes and build more robust code from the start.
The PRP (Product Requirements Prompt) workflow is a two-step process designed to ensure the AI has a comprehensive plan before writing a single line of code.
-
Generation (
generate-prp): This first step is about planning. The command takes your high-levelINITIAL.mdfeature request and asks Gemini to expand it into a detailed technical blueprint (the PRP). This blueprint includes a proposed file structure, a task breakdown, pseudocode, and a validation plan. It forces the AI to think through the entire implementation first. -
Execution (
execute-prp): This second step is about implementation. The command takes the detailed PRP and sends it back to Gemini with a clear instruction: "Build this." Because all the research and planning is already done, the AI can focus solely on writing clean, correct code that follows the blueprint.
This separation of planning from implementation is the key to the workflow's success.
The examples/ folder is your secret weapon for ensuring project consistency. AI assistants excel at pattern recognition.
-
Complete Patterns: Show a full, working example of a pattern, not just a snippet. For instance, provide a complete API client class, not just one function.
-
Code Structure: Include examples of how you structure your classes, organize your imports, and name your variables.
-
Error Handling: Show how you expect errors to be caught and handled. This is often overlooked but is critical for production-quality code.
-
Testing: Provide an example of a test file (
test_*.py) that shows your preferred testing style, including how to use mocks.
The more high-quality examples you provide, the less the AI has to guess, and the more the final code will look like you wrote it yourself.
examples/
βββ README.md # Explains what each example demonstrates
βββ api_client.py # A complete, well-structured API client
βββ data_models.py # Pydantic models or data structures
βββ tests/ # Testing patterns
βββ test_api_client.py # An example of a test file with mocks
-
Be Explicit: Never assume the AI knows your preferences. The more explicit you are in your
INITIAL.mdandGEMINI.mdfiles, the better the result will be. -
Iterate on the Process: If the AI makes a mistake, don't just fix the code. Think about why it made the mistake. Does a rule in
GEMINI.mdneed to be clearer? Do you need a better example in theexamples/folder? Improving the process will prevent the same mistake from happening again. -
Trust the Workflow: It might seem like extra work to write a detailed
INITIAL.mdand review a PRP, but this upfront investment saves a massive amount of time on debugging and refactoring later.
- Gemini CLI Repository:https://github.com/google-gemini/context-engineering-gemini
- Blog: A Practical Guide to Context Engineering with Gemini:https://aryan-gupta.is-a.dev/blog/2025/context-engineering/
- Context-Engineering-Intro: https://github.com/coleam00/context-engineering-intro
This project's workflow and the core concepts of Context Engineering were inspired by the original Context-Engineering-Intro repository by coleam00. While the code and templates have been rewritten for a Gemini-based workflow, the foundational ideas come from that excellent project.