# Claude Code Masterclass: MCP Servers From Zero to Full Stack Integration
**作者**: CyrilXBT
**日期**: 2026-05-14T02:38:19.000Z
**来源**: [https://x.com/cyrilXBT/status/2054753142173041059](https://x.com/cyrilXBT/status/2054753142173041059)
---

Most Claude Code users are building in isolation.
They write prompts. Claude generates code. They copy it into their editor. They run it. They come back with the error. They paste the error. Claude fixes it.
Every step requires a human in the middle moving information between Claude and the actual environment where the code runs.
MCP servers eliminate the middle.
When Claude Code is connected to your full stack via MCP, it does not wait for you to paste an error. It reads the error directly from the terminal. It does not wait for you to describe the database schema. It queries the schema itself. It does not suggest a Git commit message for you to copy. It makes the commit.
Claude Code with a complete MCP stack is not a code assistant.
It is a full stack engineering partner that operates directly in your environment.
This masterclass takes you from zero MCP knowledge to Claude Code connected to every layer of your stack and capable of autonomous end-to-end development workflows.
## What MCP Is and Why It Changes Everything for Claude Code
MCP stands for Model Context Protocol. It is an open standard developed by Anthropic that defines how AI models connect to external tools and data sources.
For Claude Code specifically, MCP is the bridge between Claude's code generation capabilities and the actual running systems those capabilities are supposed to work with.
Without MCP, Claude Code has three fundamental limitations.
Context blindness. Claude can only reason about code you show it. Your codebase has thousands of files. Your database has dozens of tables. Your infrastructure has dozens of services. Claude knows about none of it unless you manually provide the relevant pieces.
Action disconnect. Claude can tell you what command to run but cannot run it. It can suggest a database migration but cannot execute it. Every suggestion requires you to manually translate it into action.
Session amnesia. Every Claude Code session starts fresh. The context of your project, your conventions, your current sprint — all of it has to be re-established manually.
MCP solves all three simultaneously.
Context blindness disappears because Claude reads your actual systems directly.
Action disconnect disappears because Claude executes through MCP servers.
Session amnesia is minimized because Claude can re-read your CLAUDE.md and project context at the start of every session.
The result is a Claude Code installation that operates like a senior engineer who has been on your project for months and can work autonomously across your entire stack.
## The MCP Architecture for Full Stack Development
A full stack Claude Code setup needs MCP servers at every layer of the development environment.
The Code Layer: Filesystem and Git access. Claude reads your actual codebase, writes files directly, and manages version control.
The Data Layer: Database MCP. Claude queries schemas, reads data, writes migrations, and validates that code changes produce the expected data outcomes.
The Runtime Layer: Terminal and process execution. Claude runs tests, starts servers, reads logs, and responds to errors without you copying and pasting.
The Infrastructure Layer: Cloud provider and deployment MCP. Claude reads your infrastructure state, makes changes, and validates deployments.
The Collaboration Layer: GitHub and project management. Claude creates PRs, updates issues, and maintains documentation that stays current with the code.
Building these five layers gives you a Claude Code environment that can take a feature from specification to deployed and tested without you being the integration layer between each step.
## Setting Up the Foundation: Filesystem and Git
The first two MCP connections every Claude Code setup needs are filesystem access and Git operations.
Filesystem Setup:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/your/project",
"/path/to/your/other/projects"
]
}
}
}
Add every directory where your code lives. Claude Code can read and write any file within the specified paths.
Verify the connection:
List the top-level structure of my project directory.
Identify the main application entry point and describe
the overall architecture based on what you find.
If Claude accurately describes your project structure the filesystem MCP is working.
Git Setup:
"git": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-git"],
"env": {
"GIT_REPO_PATH": "/path/to/your/project"
}
}
Verify:
Show me the last 10 commits in this repository.
What was the most significant change made in the
last week based on the commit messages and diffs?
With filesystem and Git connected, Claude Code can read your entire codebase and manage version control. This alone transforms the quality of code suggestions because Claude is working with your actual code rather than hypothetical examples.
## The Data Layer: Database MCP
The database layer is where most Claude Code setups are incomplete.
Without database MCP, every time Claude writes code that touches the database it is making assumptions about your schema. Those assumptions are often wrong. The code needs debugging not because Claude's logic was flawed but because it did not know your actual data model.
With database MCP, Claude reads your real schema before writing a single line of database code. It knows your exact table names, column names, types, and relationships. The code it produces works the first time at a significantly higher rate.
PostgreSQL Setup:
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost:5432/dbname"
]
}
Supabase Setup:
"supabase": {
"command": "npx",
"args": ["-y", "@supabase/mcp-server-supabase"],
"env": {
"SUPABASE_URL": "https://your-project.supabase.co",
"SUPABASE_SERVICE_KEY": "your-service-role-key"
}
}
Use the service role key for development environments where Claude needs full database access. Use a read-only key for environments where you want Claude to query but not modify data.
The Database Context Prompt:
Run this at the start of any session involving database work:
Read the complete schema of my database including:
- All table names and their columns with types
- All foreign key relationships
- All indexes
- Any views or functions
Based on what you find, describe the data model and
identify any potential issues with the current schema.
Claude now knows your data model as well as you do. The code it writes for any database operation will be schema-accurate from the first attempt.
Writing Migrations with Database MCP:
I need to add a new feature: [FEATURE DESCRIPTION]
Based on the current schema you have read:
1. Identify what tables need to be created or modified
2. Write the migration file with proper up and down methods
3. Identify any existing queries that might be affected
4. Write the updated queries that work with the new schema
5. Run the migration and verify it applied correctly
Do all of this directly. Read the schema, write the migration,
apply it, and confirm the result.
Claude reads the current schema, writes a migration that accounts for your actual data model, applies it, and verifies the result. You never manually copy a migration file.
## The Runtime Layer: Terminal and Process Execution
This is the MCP connection that makes Claude Code genuinely autonomous.
Without terminal access, every time Claude writes code you have to run it manually, copy the output or error, paste it back, and wait for Claude to respond. For development workflows involving multiple test runs and iterations, this loop costs enormous time.
With terminal MCP, Claude runs the code itself. It reads the output. If there is an error it reads the error directly and fixes it without you in the loop. It runs the tests and reads the results. It starts a development server and hits the endpoints to verify behavior.
Terminal Setup:
The terminal MCP requires careful permission configuration. You are giving Claude the ability to execute commands on your machine. Define the scope clearly.
"terminal": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-terminal"],
"env": {
"ALLOWED_COMMANDS": "npm,node,git,python,pip,curl,ls,cat,grep,find",
"WORKING_DIRECTORY": "/path/to/your/project",
"TIMEOUT_SECONDS": "30"
}
}
The ALLOWED_COMMANDS list is critical. Include only the commands Claude needs for development. Do not include commands that could modify system configuration or access sensitive areas.
The Test-Driven Development Loop:
Implement the following feature: [FEATURE DESCRIPTION]
Follow this exact process:
1. Read the existing code in [RELEVANT FILES]
2. Write the tests first based on the feature requirements
3. Run the tests to confirm they fail (red)
4. Write the implementation
5. Run the tests again to confirm they pass (green)
6. Refactor if needed
7. Run the full test suite to confirm nothing broke
8. Commit with a descriptive message
Do each step autonomously. Read and run without waiting
for my input between steps.
Claude writes tests, runs them, implements the feature, runs tests again, and commits. The entire TDD cycle runs without you touching anything.
The Bug Fix Loop:
There is a bug: [DESCRIBE THE BUG OR PASTE THE ERROR]
To fix it:
1. Read the relevant source files
2. Run the code that produces the error and observe the output
3. Identify the root cause from the actual error output
4. Fix the code
5. Run the code again to verify the fix
6. Run the full test suite to ensure nothing else broke
7. Commit the fix
Do not ask me for additional information. Read what you need
directly and fix it.
This prompt is worth dozens of hours of back-and-forth debugging sessions. Claude runs the code, reads the actual error, fixes the actual cause, and verifies the fix — all without you copying and pasting anything.
## The Infrastructure Layer: Cloud and Deployment MCP
The infrastructure layer connects Claude Code to where your code actually runs.
AWS Setup:
"aws": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-aws"],
"env": {
"AWS_ACCESS_KEY_ID": "your-key-id",
"AWS_SECRET_ACCESS_KEY": "your-secret",
"AWS_REGION": "your-region"
}
}
Use an IAM user with limited permissions scoped to the services Claude needs. Do not use root credentials.
Vercel Setup:
"vercel": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-vercel"],
"env": {
"VERCEL_TOKEN": "your-token"
}
}
The Full Deployment Workflow:
Deploy the latest changes to production.
Process:
1. Read the current git status and pending changes
2. Run the full test suite - abort if any tests fail
3. Build the production bundle and verify it completes
4. Check the current production deployment status
5. Deploy to staging environment first
6. Run smoke tests against staging
7. If staging passes, deploy to production
8. Verify the production deployment is healthy
9. Create a deployment record in [YOUR TRACKING SYSTEM]
Do not proceed past any failing step. Report what happened
and stop if anything fails.
This workflow runs end to end. Tests, build, staging deployment, smoke tests, production deployment, health check. You get a report when it is done or a specific failure report if something goes wrong.
## The Collaboration Layer: GitHub and Project Management
The collaboration layer keeps your team context current with what Claude Code is actually doing.
GitHub MCP Setup:
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token"
}
}
Linear MCP Setup:
"linear": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-linear"],
"env": {
"LINEAR_API_KEY": "your-key"
}
}
The Feature Development Workflow:
I am starting work on Linear issue [ISSUE ID].
Complete workflow:
1. Read the Linear issue for full requirements and acceptance criteria
2. Read any related issues or linked resources in Linear
3. Check if there is an existing branch for this issue
4. Create a new branch if needed: feature/[issue-id]-[description]
5. Read the relevant existing code to understand the context
6. Implement the feature according to the acceptance criteria
7. Write tests covering all acceptance criteria
8. Run the full test suite
9. If all tests pass: create a PR with:
- Title linking to the Linear issue
- Description summarizing what was built
- List of acceptance criteria met
- Any notes for the reviewer
10. Update the Linear issue status to In Review
Work through all steps without stopping for input.
Claude reads the ticket, implements the feature, writes tests, and creates the PR. The Linear issue updates automatically. You get a PR ready for review.
## The CLAUDE.md That Governs Your Full Stack Setup
With all five layers connected, the CLAUDE.md becomes the master context document that makes Claude Code act like a senior engineer who knows your entire stack.
# Full Stack Development Environment — CLAUDE.md
## Project Overview
Project: [NAME]
Stack: [YOUR FULL TECH STACK]
Architecture: [BRIEF DESCRIPTION]
Deployment: [WHERE IT RUNS]
## Connected Systems
- Filesystem: Project at [PATH], other projects at [PATH]
- Git: Primary repo [REPO NAME], default branch [BRANCH]
- Database: [TYPE] at [CONNECTION], [READ/WRITE] access
- Terminal: Allowed commands listed in MCP config
- GitHub: Primary repo [OWNER/REPO]
- Linear: Team [TEAM NAME], my user [USERNAME]
- Cloud: [PROVIDER], primary region [REGION]
## Development Standards
Language conventions: [YOUR CONVENTIONS]
File naming: [YOUR PATTERNS]
Test framework: [WHAT YOU USE]
Test coverage requirement: [YOUR MINIMUM]
Commit message format: [YOUR FORMAT]
## Architecture Decisions
[List key architectural decisions and why they were made]
[Claude should not reverse these without discussion]
## Current Sprint Context
[UPDATE WEEKLY]
Sprint goal: [CURRENT SPRINT GOAL]
My current focus: [WHAT YOU ARE WORKING ON]
Active Linear issues: [ISSUE IDS]
## Code Quality Rules
- Never commit directly to main
- All PRs need passing tests before requesting review
- Database migrations must have both up and down methods
- All new functions need JSDoc or equivalent documentation
## Deployment Rules
- Never deploy to production without passing staging tests
- Always create a deployment record after production deploy
- Rollback procedure: [YOUR ROLLBACK PROCESS]
## Emergency Rules
If you encounter: [SPECIFIC DANGEROUS SITUATION]
Do: [SPECIFIC SAFE ACTION]
Never: [THINGS THAT COULD CAUSE SERIOUS PROBLEMS]
## The Week-by-Week Build Plan
Week 1: Filesystem and Git
Install both servers. Spend the week using Claude Code for code review, refactoring, and documentation. Get comfortable with Claude reading your actual codebase before adding more servers.
Target workflow: Ask Claude to review any file in your project and suggest improvements. Have it implement one improvement, test it manually, and commit it.
Week 2: Database
Add your database MCP. Ask Claude to read your schema at the start of every database-related session. Have it write one migration that you would have written manually.
Target workflow: Full migration cycle. Claude reads schema, writes migration, applies it, writes the application code that uses the new schema, runs existing tests.
Week 3: Terminal
This is the most significant capability jump. Start with a constrained allowed commands list. Expand it only as you build trust in Claude's execution judgment.
Target workflow: Complete TDD cycle for one small feature. Claude writes tests, runs them, implements, runs again, commits.
Week 4: GitHub and Linear
Add the collaboration layer. Start using it for PR creation and issue management.
Target workflow: Pick a Linear issue, let Claude read it and implement it from ticket to PR without you describing the requirements.
Week 5: Infrastructure
Add cloud MCP with read-only access first. Once you are comfortable with what Claude reads and how it behaves, extend to write access for deployments.
Target workflow: Full deployment pipeline on a non-critical feature. Staging to production with all gates.
Week 6: Integration and Optimization
Run complex multi-system workflows that combine all five layers. Identify remaining manual steps and build the connections to eliminate them.
## What Full Stack MCP Integration Actually Produces
When all five layers are connected and the CLAUDE.md is properly configured, the development experience changes at a fundamental level.
Features move from specification to deployed faster. Not because Claude generates code faster than you type. Because the feedback loops that slow development — running tests manually, checking the database manually, managing PRs manually — all happen inside the same Claude session without breaking flow.
Bug fix cycles compress dramatically. Claude reads the actual error from the running system rather than a copy-pasted error message. It reads the relevant code in context. It fixes the actual problem, not the described problem.
Documentation stays current automatically. Every PR Claude creates includes accurate documentation because Claude read the code it is documenting rather than summarizing what you told it.
Context quality improves across sessions. Claude reads your CLAUDE.md at the start of every session. The architecture decisions, conventions, and current sprint context inform every suggestion before you ask your first question.
The engineers who build this setup are not doing more work.
They are doing better work with less friction at every layer.
The terminal is not a boundary between Claude and your stack anymore.
The stack is Claude's environment.
Build the first layer this weekend.
The rest follows naturally from there.
Follow @cyrilXBT for the exact configurations, CLAUDE.md templates, and workflow prompts that power this entire setup.
## 相关链接
- [CyrilXBT reposted](https://x.com/cyrilXBT)
- [CyrilXBT](https://x.com/cyrilXBT)
- [@cyrilXBT](https://x.com/cyrilXBT)
- [18K](https://x.com/cyrilXBT/status/2054753142173041059/analytics)
- [@modelcontextprotocol/server-filesystem](https://x.com/@modelcontextprotocol/server-filesystem)
- [@modelcontextprotocol/server-git](https://x.com/@modelcontextprotocol/server-git)
- [@modelcontextprotocol/server-postgres](https://x.com/@modelcontextprotocol/server-postgres)
- [@supabase/mcp-server-supabase](https://x.com/@supabase/mcp-server-supabase)
- [https://your-project.supabase.co](https://your-project.supabase.co/)
- [@modelcontextprotocol/server-terminal](https://x.com/@modelcontextprotocol/server-terminal)
- [@modelcontextprotocol/server-aws](https://x.com/@modelcontextprotocol/server-aws)
- [@modelcontextprotocol/server-vercel](https://x.com/@modelcontextprotocol/server-vercel)
- [@modelcontextprotocol/server-github](https://x.com/@modelcontextprotocol/server-github)
- [@modelcontextprotocol/server-linear](https://x.com/@modelcontextprotocol/server-linear)
- [@cyrilXBT](https://x.com/@cyrilXBT)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [10:38 AM · May 14, 2026](https://x.com/cyrilXBT/status/2054753142173041059)
- [18.4K Views](https://x.com/cyrilXBT/status/2054753142173041059/analytics)
- [View quotes](https://x.com/cyrilXBT/status/2054753142173041059/quotes)
---
*导出时间: 2026/5/15 09:40:09*
---
## 中文翻译
# Claude Code 大师课:MCP 服务器从零到全栈集成
**作者**: CyrilXBT
**日期**: 2026-05-14T02:38:19.000Z
**来源**: [https://x.com/cyrilXBT/status/2054753142173041059](https://x.com/cyrilXBT/status/2054753142173041059)
---

大多数 Claude Code 用户都在孤立地进行开发。
他们编写提示词。Claude 生成代码。他们把代码复制到编辑器里。运行代码。遇到错误后回来。粘贴错误信息。Claude 修复错误。
每一步都需要人类在中间介入,在 Claude 和代码运行的实际环境之间传递信息。
MCP 服务器消除了这个中间环节。
当 Claude Code 通过 MCP 连接到你的全栈环境时,它不会等待你粘贴错误信息。它直接从终端读取错误。它不会等待你描述数据库模式(Schema)。它自己查询模式。它不会建议你复制一条 Git 提交信息。它直接执行提交。
配备完整 MCP 栈的 Claude Code 不是一个代码助手。
它是一个直接在你的环境中工作的全栈工程伙伴。
这门大师课将带你从零 MCP 知识起步,让 Claude Code 连接到你技术栈的每一层,并能够执行自主的端到端开发工作流。
## 什么是 MCP 以及它为何彻底改变 Claude Code
MCP 代表模型上下文协议(Model Context Protocol)。这是由 Anthropic 开发的一个开放标准,定义了 AI 模型如何连接到外部工具和数据源。
具体对于 Claude Code 来说,MCP 是 Claude 的代码生成能力与这些能力实际要操作的运行系统之间的桥梁。
如果没有 MCP,Claude Code 有三个根本性的局限性。
上下文盲区。Claude 只能推理你展示给它的代码。你的代码库有数千个文件。你的数据库有几十张表。你的基础设施有几十个服务。除非你手动提供相关片段,否则 Claude 对这些一无所知。
行动断层。Claude 可以告诉你运行什么命令,但无法运行它。它可以建议数据库迁移,但无法执行它。每一个建议都需要你手动将其转化为行动。
会话失忆。每次 Claude Code 会话都是全新的。你的项目上下文、你的约定、你当前的冲刺——所有这些都必须手动重新建立。
MCP 同时解决了这三个问题。
上下文盲区消失了,因为 Claude 直接读取你的实际系统。
行动断层消失了,因为 Claude 通过 MCP 服务器执行操作。
会话失忆被最小化,因为 Claude 可以在每次会话开始时重新读取你的 CLAUDE.md 和项目上下文。
结果就是一个像在你项目上工作了数月的资深工程师一样运作的 Claude Code 安装环境,能够跨越整个技术栈自主工作。
## 全栈开发的 MCP 架构
一个全栈 Claude Code 设置需要在开发环境的每一层都部署 MCP 服务器。
代码层:文件系统和 Git 访问。Claude 读取你的实际代码库,直接写入文件,并管理版本控制。
数据层:数据库 MCP。Claude 查询模式,读取数据,写入迁移,并验证代码更改是否产生了预期的数据结果。
运行时层:终端和进程执行。Claude 运行测试,启动服务器,读取日志,并响应错误,无需你复制粘贴。
基础设施层:云提供商和部署 MCP。Claude 读取你的基础设施状态,进行更改,并验证部署。
协作层:GitHub 和项目管理。Claude 创建 PR,更新 Issue,并维护与代码同步的最新文档。
构建这五层将为你提供一个 Claude Code 环境,可以将一个功能从规范变成已部署和已测试的状态,而无需你充当每一步之间的集成层。
## 搭建基础:文件系统和 Git
每个 Claude Code 设置都需要的前两个 MCP 连接是文件系统访问和 Git 操作。
文件系统设置:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/your/project",
"/path/to/your/other/projects"
]
}
}
}
添加你代码所在的每个目录。Claude Code 可以读取和写入指定路径内的任何文件。
验证连接:
列出我项目目录的顶层结构。
基于你发现的内容,识别主应用程序入口点并描述整体架构。
如果 Claude 准确描述了你的项目结构,说明文件系统 MCP 正常工作。
Git 设置:
"git": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-git"],
"env": {
"GIT_REPO_PATH": "/path/to/your/project"
}
}
验证:
显示此仓库中最近的 10 次提交。
基于提交信息和差异,过去一周最重大的变更是什么?
连接了文件系统和 Git 后,Claude Code 可以读取你的整个代码库并管理版本控制。仅这一点就能提高代码建议的质量,因为 Claude 处理的是你的实际代码,而不是假设性的例子。
## 数据层:数据库 MCP
数据库层是大多数 Claude Code 设置不完整的地方。
如果没有数据库 MCP,每次 Claude 编写涉及数据库的代码时,它都在对你的模式做出假设。这些假设往往是错误的。代码需要调试,不是因为 Claude 的逻辑有缺陷,而是因为它不知道你的实际数据模型。
有了数据库 MCP,Claude 在编写一行数据库代码之前会先读取你的真实模式。它知道你确切的表名、列名、类型和关系。它生成的代码在第一次运行时的成功率要高得多。
PostgreSQL 设置:
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost:5432/dbname"
]
}
Supabase 设置:
"supabase": {
"command": "npx",
"args": ["-y", "@supabase/mcp-server-supabase"],
"env": {
"SUPABASE_URL": "https://your-project.supabase.co",
"SUPABASE_SERVICE_KEY": "your-service-role-key"
}
}
在 Claude 需要完全数据库访问权限的开发环境中使用服务角色密钥。在你希望 Claude 查询但不修改数据的环境中,使用只读密钥。
数据库上下文提示词:
在任何涉及数据库工作的会话开始时运行此命令:
读取我数据库的完整模式,包括:
- 所有表名及其列和类型
- 所有外键关系
- 所有索引
- 任何视图或函数
基于你的发现,描述数据模型并识别当前模式中的任何潜在问题。
现在 Claude 对你的数据模型的了解和你一样透彻。它为任何数据库操作编写的代码将在第一次尝试时就符合模式要求。
使用数据库 MCP 编写迁移:
我需要添加一个新功能:[功能描述]
基于你读取的当前模式:
1. 识别需要创建或修改哪些表
2. 编写包含正确 up 和 down 方法的迁移文件
3. 识别可能受影响的任何现有查询
4. 编写适用于新模式的新查询
5. 运行迁移并验证它是否正确应用
直接完成所有这些操作。读取模式,编写迁移,应用它,并确认结果。
Claude 读取当前模式,编写一个考虑了你实际数据模型的迁移,应用它,并验证结果。你永远不需要手动复制迁移文件。
## 运行时层:终端和进程执行
这是让 Claude Code 真正自主的 MCP 连接。
如果没有终端访问权限,每次 Claude 编写代码时,你都必须手动运行它,复制输出或错误,粘贴回来,然后等待 Claude 响应。对于涉及多次测试运行和迭代的开发工作流,这个循环会耗费大量时间。
有了终端 MCP,Claude 自己运行代码。它读取输出。如果有错误,它直接读取错误并修复,无需你介入循环。它运行测试并读取结果。它启动开发服务器并访问端点以验证行为。
终端设置:
终端 MCP 需要仔细配置权限。你正在赋予 Claude 在你的机器上执行命令的能力。明确定义范围。
"terminal": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-terminal"],
"env": {
"ALLOWED_COMMANDS": "npm,node,git,python,pip,curl,ls,cat,grep,find",
"WORKING_DIRECTORY": "/path/to/your/project",
"TIMEOUT_SECONDS": "30"
}
}
ALLOWED_COMMANDS 列表至关重要。只包含 Claude 开发所需的命令。不要包含可能修改系统配置或访问敏感区域的命令。
测试驱动开发(TDD)循环:
实现以下功能:[功能描述]
遵循这个精确的过程:
1. 读取 [相关文件] 中的现有代码
2. 根据功能需求先编写测试
3. 运行测试以确认它们失败(红色)
4. 编写实现代码
5. 再次运行测试以确认它们通过(绿色)
6. 如果需要,进行重构
7. 运行完整的测试套件以确认没有破坏任何东西
8. 提交并附带描述性信息
自主地执行每一步。读取并运行,无需等待我在步骤之间输入。
Claude 编写测试,运行它们,实现功能,再次运行测试,并提交。整个 TDD 周期无需你触碰任何东西即可运行。
错误修复循环:
有一个错误:[描述错误或粘贴错误信息]
要修复它:
1. 读取相关的源文件
2. 运行产生错误的代码并观察输出
3. 从实际错误输出中识别根本原因
4. 修复代码
5. 再次运行代码以验证修复
6. 运行完整的测试套件以确保没有破坏其他任何东西
7. 提交修复
不要向我询问额外信息。直接读取你需要的内容并修复它。
这个提示词值得数十小时来回调试的会话时间。Claude 运行代码,读取实际错误,修复实际原因,并验证修复——所有这些都不需要你复制粘贴任何东西。
## 基础设施层:云和部署 MCP
基础设施层将 Claude Code 连接到你的代码实际运行的地方。
AWS 设置:
"aws": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-aws"],
"env": {
"AWS_ACCESS_KEY_ID": "your-key-id",
"AWS_SECRET_ACCESS_KEY": "your-secret",
"AWS_REGION": "your-region"
}
}
使用权限范围仅限于 Claude 所需服务的 IAM 用户。不要使用根凭证。
Vercel 设置:
"vercel": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-vercel"],
"env": {
"VERCEL_TOKEN": "your-token"
}
}
完整部署工作流:
将最新更改部署到生产环境。
流程:
1. 读取当前的 git 状态和待处理的更改
2. 运行完整的测试套件 - 如果有任何测试失败则中止
3. 构建生产包并验证它完成
4. 检查当前生产部署状态
5. 首先部署到暂存环境
6. 对暂存环境运行冒烟测试
7. 如果暂存通过,部署到生产环境
8. 验证生产部署是否健康
9. 在 [你的跟踪系统] 中创建部署记录
在任何失败的步骤之后都不要继续。报告发生了什么,如果出现任何问题则停止。
此工作流端到端运行。测试、构建、暂存部署、冒烟测试、生产部署、健康检查。完成后你会收到一份报告,如果出现问题则会收到具体的失败报告。
## 协作层:GitHub 和项目管理
协作层使你的团队上下文与 Claude Code 实际正在做的事情保持同步。
GitHub MCP 设置:
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token"
}
}
Linear MCP 设置:
"linear": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-linear"],
"env": {
"LINEAR_API_KEY": "your-key"
}
}
功能开发工作流:
我开始处理 Linear Issue [ISSUE ID]。
完整工作流:
1. 阅读 Linear Issue 以了解全部需求和验收标准
2. 阅读 Linear 中任何相关的 Issue 或关联资源
3. 检查此 Issue 是否已存在分支
4. 如有需要,创建新分支:feature/[issue-id]-[description]
5. 阅读相关的现有代码以了解上下文
6. 根据验收标准实现功能
7. 编写涵盖所有验收标准的测试
8. 运行完整的测试套件
9. 如果所有测试通过:创建一个 PR,包含:
- 链接到 Linear Issue 的标题
- 总结所构建内容的描述
- 已满足的验收标准列表
- 给审查者的任何备注
10. 将 Linear Issue 状态更新为 In Review
完成所有步骤,无需停下来等待输入。
Claude 读取票据,实现功能,编写测试,并创建 PR。Linear Issue 自动更新。你会得到一个准备好供审查的 PR。
## 管理全栈设置的 CLAUDE.md
连接了所有五层后,CLAUDE.md 就成为主上下文文档,使 Claude Code 表现得像一位了解你整个技术栈的资深工程师。
# 全栈开发环境 — CLAUDE.md
## 项目概述
项目:[名称]
技术栈:[你的完整技术栈]
架构:[简要描述]
部署:[运行位置]
## 已连接的系统
- 文件系统:项目位于 [路径],其他项目位于 [路径]
- Git:主仓库 [仓库名称],默认分支 [分支名称]
- 数据库:[类型] 位于 [连接],[读/写] 访问权限
- 终端:允许的命令列在 MCP 配置中
- GitHub:主仓库 [所有者/仓库]
- Linear:团队 [团队名称],我的用户 [用户名]
- 云:[提供商],主要区域 [区域]
## 开发标准
语言约定:[你的约定]
文件命名:[你的模式]
测试框架:[你使用的工具]
测试覆盖率要求:[你的最低要求]
提交信息格式:[你的格式]
## 架构决策
[列出关键架构决策及其做出原因]
[未经讨论,Claude 不应推翻这些决策]
## 当前冲刺上下文
[每周更新]
冲刺目标:[当前冲刺目标]
我当前的重点:[你正在处理的工作]
活跃的 Linear Issues:[Issue ID]
## 代码质量规则
- 永远不要直接提交到 main 分支
- 所有 PR 在请求审查前必须通过测试
- 数据库迁移必须包含 up 和 down 方法
- 所有新函数都需要 JSDoc 或等效文档
## 部署规则
- 没有通过暂存测试永远不要部署到生产环境
- 生产部署后始终创建部署记录
- 回滚程序:[你的回滚过程]
## 紧急规则
如果你遇到:[具体的危险情况]
执行:[具体的安全操作]
切勿:[可能导致严重问题的事情]
## 逐周构建计划
第一周:文件系统和 Git
安装这两个服务器。本周使用 Claude Code 进行代码审查、重构和文档编写。在添加更多服务器之前,先习惯 Claude 读取你的实际代码库。
目标工作流:要求 Claude 审查项目中的任何文件并提出改进建议。让它实施一项改进,手动测试,然后提交。
第二周:数据库
添加你的数据库 MCP。在每个与数据库相关的会话开始时,要求 Claude 读取你的模式。让它编写一个原本需要你手动编写的迁移。
目标工作流:完整的迁移周期。Claude 读取模式,编写迁移,应用它,编写使用新模式的应用程序代码,运行现有测试。
第三周:终端
这是最重大的能力飞跃。从受限的允许命令……