Note
本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
English · 原始项目 · 上游 README
原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
这是一份用于入门 Context Engineering(上下文工程)的综合模板——这门学科致力于为大模型编程助手构建上下文,使其掌握端到端完成任务所需的信息。
Context Engineering 比 prompt engineering(提示工程)好 10 倍,比 vibe coding(凭感觉写代码)好 100 倍。
# 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
Context Engineering 代表了相对传统 prompt engineering 的范式转变:
Prompt Engineering:
Context Engineering:
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
本模板暂不聚焦将 RAG 与工具纳入 context engineering,因为这方面我还有更多内容即将推出。;)
CLAUDE.md 文件包含 AI 助手在每次对话中都会遵循的项目级规则。模板包括:
你可以直接使用提供的模板,也可以按项目自行定制。
编辑 INITIAL.md,描述你想构建的内容:
## 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]
完整示例见 INITIAL_EXAMPLE.md。
PRP(Product Requirements Prompts,产品需求提示)是包含以下内容的综合实现蓝图:
它们与 PRD(Product Requirements Documents,产品需求文档)类似,但更为专门地用于指导 AI 编程助手。
在 Claude Code 中运行:
/generate-prp INITIAL.md
注意: 这些斜杠命令是在 .claude/commands/ 中定义的自定义命令。你可以查看其实现:
.claude/commands/generate-prp.md —— 了解其如何调研并创建 PRP.claude/commands/execute-prp.md —— 了解其如何根据 PRP 实现功能这些命令中的 $ARGUMENTS 变量会接收你在命令名之后传入的参数(例如 INITIAL.md 或 PRPs/your-feature.md)。
该命令将:
PRPs/your-feature-name.md 中创建完整的 PRP生成后,执行 PRP 以实现你的功能:
/execute-prp PRPs/your-feature-name.md
AI 编程助手将:
FEATURE:具体且全面
EXAMPLES:善用 examples/ 文件夹
examples/DOCUMENTATION:包含所有相关资源
OTHER CONSIDERATIONS:记录重要细节
该命令遵循以下流程:
调研阶段
文档收集
蓝图创建
质量检查
生成内容的完整示例见 PRPs/EXAMPLE_multi_agent_prp.md。
examples/ 文件夹对成功至关重要。当 AI 编程助手能看到可遵循的模式时,表现会好得多。
代码结构模式
测试模式
集成模式
CLI 模式
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