context-engineering-intro README

The project's README from github.com/coleam00/context-engineering-intro. As one markdown file: README.md.

Context Engineering Template

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.

🚀 Quick Start

# 1. Clone this template
git clone https://github.com/coleam00/Context-Engineering-Intro.git
cd Context-Engineering-Intro

# 2. Set up your project rules (optional - template provided)
# Edit CLAUDE.md to add your project-specific guidelines

# 3. Add examples (highly recommended)
# Place relevant code examples in the examples/ folder

# 4. Create your initial feature request
# Edit INITIAL.md with your feature requirements

# 5. Generate a comprehensive PRP (Product Requirements Prompt)
# In Claude Code, run:
/generate-prp INITIAL.md

# 6. Execute the PRP to implement your feature
# In Claude Code, run:
/execute-prp PRPs/your-feature-name.md

📚 Table of Contents

What is Context Engineering?

Context Engineering represents a paradigm shift from traditional prompt engineering:

Prompt Engineering vs Context Engineering

Prompt Engineering:

Context Engineering:

Why Context Engineering Matters

  1. Reduces AI Failures: Most agent failures aren't model failures - they're context failures
  2. Ensures Consistency: AI follows your project patterns and conventions
  3. Enables Complex Features: AI can handle multi-step implementations with proper context
  4. Self-Correcting: Validation loops allow AI to fix its own mistakes

Template Structure

context-engineering-intro/
├── .claude/
│   ├── commands/
│   │   ├── generate-prp.md    # Generates comprehensive PRPs
│   │   └── execute-prp.md     # Executes PRPs to implement features
│   └── settings.local.json    # Claude Code permissions
├── PRPs/
│   ├── templates/
│   │   └── prp_base.md       # Base template for PRPs
│   └── EXAMPLE_multi_agent_prp.md  # Example of a complete PRP
├── examples/                  # Your code examples (critical!)
├── CLAUDE.md                 # Global rules for AI assistant
├── INITIAL.md               # Template for feature requests
├── INITIAL_EXAMPLE.md       # Example feature request
└── README.md                # This file

This template doesn't focus on RAG and tools with context engineering because I have a LOT more in store for that soon. ;)

Step-by-Step Guide

1. Set Up Global Rules (CLAUDE.md)

The CLAUDE.md file contains project-wide rules that the AI assistant will follow in every conversation. The template includes:

You can use the provided template as-is or customize it for your project.

2. Create Your Initial Feature Request

Edit INITIAL.md to describe what you want to build:

## FEATURE:
[Describe what you want to build - be specific about functionality and requirements]

## EXAMPLES:
[List any example files in the examples/ folder and explain how they should be used]

## DOCUMENTATION:
[Include links to relevant documentation, APIs, or MCP server resources]

## OTHER CONSIDERATIONS:
[Mention any gotchas, specific requirements, or things AI assistants commonly miss]

See INITIAL_EXAMPLE.md for a complete example.

3. Generate the PRP

PRPs (Product Requirements Prompts) are comprehensive implementation blueprints that include:

They are similar to PRDs (Product Requirements Documents) but are crafted more specifically to instruct an AI coding assistant.

Run in Claude Code:

/generate-prp INITIAL.md

Note: The slash commands are custom commands defined in .claude/commands/. You can view their implementation:

The $ARGUMENTS variable in these commands receives whatever you pass after the command name (e.g., INITIAL.md or PRPs/your-feature.md).

This command will:

  1. Read your feature request
  2. Research the codebase for patterns
  3. Search for relevant documentation
  4. Create a comprehensive PRP in PRPs/your-feature-name.md

4. Execute the PRP

Once generated, execute the PRP to implement your feature:

/execute-prp PRPs/your-feature-name.md

The AI coding assistant will:

  1. Read all context from the PRP
  2. Create a detailed implementation plan
  3. Execute each step with validation
  4. Run tests and fix any issues
  5. Ensure all success criteria are met

Writing Effective INITIAL.md Files

Key Sections Explained

FEATURE: Be specific and comprehensive

EXAMPLES: Leverage the examples/ folder

DOCUMENTATION: Include all relevant resources

OTHER CONSIDERATIONS: Capture important details

The PRP Workflow

How /generate-prp Works

The command follows this process:

  1. Research Phase

    • Analyzes your codebase for patterns
    • Searches for similar implementations
    • Identifies conventions to follow
  2. Documentation Gathering

    • Fetches relevant API docs
    • Includes library documentation
    • Adds gotchas and quirks
  3. Blueprint Creation

    • Creates step-by-step implementation plan
    • Includes validation gates
    • Adds test requirements
  4. Quality Check

    • Scores confidence level (1-10)
    • Ensures all context is included

How /execute-prp Works

  1. Load Context: Reads the entire PRP
  2. Plan: Creates detailed task list using TodoWrite
  3. Execute: Implements each component
  4. Validate: Runs tests and linting
  5. Iterate: Fixes any issues found
  6. Complete: Ensures all requirements met

See PRPs/EXAMPLE_multi_agent_prp.md for a complete example of what gets generated.

Using Examples Effectively

The examples/ folder is critical for success. AI coding assistants perform much better when they can see patterns to follow.

What to Include in Examples

  1. Code Structure Patterns

    • How you organize modules
    • Import conventions
    • Class/function patterns
  2. Testing Patterns

    • Test file structure
    • Mocking approaches
    • Assertion styles
  3. Integration Patterns

    • API client implementations
    • Database connections
    • Authentication flows
  4. CLI Patterns

    • Argument parsing
    • Output formatting
    • Error handling

Example Structure

examples/
├── README.md           # Explains what each example demonstrates
├── cli.py             # CLI implementation pattern
├── agent/             # Agent architecture patterns
│   ├── agent.py      # Agent creation pattern
│   ├── tools.py      # Tool implementation pattern
│   └── providers.py  # Multi-provider pattern
└── tests/            # Testing patterns
    ├── test_agent.py # Unit test patterns
    └── conftest.py   # Pytest configuration

Best Practices

1. Be Explicit in INITIAL.md

2. Provide Comprehensive Examples

3. Use Validation Gates

4. Leverage Documentation

5. Customize CLAUDE.md

Resources

context-engineering-intro (coleam00/context-engineering-intro)

Searching Database…

这是什么?一套用于练习上下文工程(context engineering)的完整模板:为 Claude Code 这类 AI 编程助手提供完成整个功能开发所需的文档、示例和规则。
这是需要安装的应用,还是复制到自己项目里的一组文件?它是一个供你复制的模板仓库,不是应用:包含一个 CLAUDE.md 规则文件、一个 INITIAL.md 功能需求文件、一个 examples/ 文件夹,以及两个自定义的 Claude Code 斜杠命令,你可以根据自己的项目进行调整。
拿到之后,具体的工作流程是怎样的?先在 INITIAL.md 里描述你要的功能,然后运行 /generate-prp 让它研究代码库并把一份蓝图写入 PRPs/,接着运行 /execute-prp,助手就会规划、实现并不断迭代,直到测试全部通过。
必须用 Claude Code 吗,还是换别的 AI 助手也行?它是围绕 Claude Code 构建的——/generate-prp 和 /execute-prp 这两个命令位于 .claude/commands/ 中——不过仓库描述里提到,同样的方法也可以配合任何 AI 编程助手来用。
它有没有刻意不包含的内容?RAG 和工具(tools)目前不在范围内——作者表示这方面他还有更多计划——所以这个模板目前只涵盖全局规则、功能需求和 PRP 工作流。
上下文工程和提示词工程有什么区别?提示词工程是对单个任务做巧妙的措辞——就像一张便利贴。上下文工程则是一整套由文档、示例、规则、模式和校验组成的系统——就像一部完整的剧本。作者称它比提示词工程好 10 倍,比凭感觉写代码(vibe coding)好 100 倍。
PRP 到底是什么?PRP 是产品需求提示词(Product Requirements Prompt):一份实现蓝图,包含完整的上下文和文档、带校验关卡的逐步实现说明、错误处理模式和测试要求——有点像 PRD,但专门写给 AI 编程助手看的。
为什么 examples/ 文件夹这么重要?因为 AI 助手在有可参考的模式时表现会好得多。你可以把自己项目里的代码结构、测试、集成和 CLI 方面的模式放到这个文件夹里——既展示该怎么做,也展示不该怎么做——这样生成的代码就能符合你的项目惯例。
Creator
coleam00
Size
1.5 MB
Stars
13.9K
Updated
CommitMar 16
Age
1y
Commits · 90 Days