Ask AI to build a to-do app from scratch in an empty repository, and almost anyone will be impressed. The real test is different: connect an AI coding tool to a project with tens of thousands of lines of code, five years of history, countless implicit conventions, and accumulated technical debt, then have it make the right change without breaking anything. When the integration is poorly prepared, the AI either writes textbook-correct code that clashes with the project or damages parts of the system it never understood.
This article does not explain where to click in a particular tool. It explains how to prepare an existing project for AI assistance: how to give the AI project context, establish permission boundaries, and choose the situations that suit each of three leading tools.
Roughly 80 percent of a successful integration comes down to the quality of the project context you give the AI.
Before Integration: Help the AI Understand Your Project
The fundamental difference between an existing project and a toy is the set of conventions the code never states explicitly: which state-management system the project uses, how it handles errors, its naming style, which directories are off-limits, and how to run the build and tests. A new human teammate learns those things over several weeks. Every AI session begins with a newcomer, so you must document the conventions explicitly.
First, write a project-instructions file. Leading tools support a context file in the repository root and load it automatically into each session:
- Claude Code:
CLAUDE.md - Cursor:
.cursor/rules/*.mdc(or the older.cursorrules) - Codex and other tools:
AGENTS.md, which is gradually becoming a cross-tool convention
What belongs in this file? Do not merely copy the README. Document the details the AI is most likely to misunderstand and the project does not otherwise spell out:
## 技术栈与约定
- 前端 Next.js,状态用 X,不要引入 Redux
- 所有 API 错误走 handleError(),不要自己 try/catch 直接吞
## 目录规则
- 只在 src/features 下加新功能;src/legacy 是待废弃代码,不要动
- 数据生成脚本产物放 data/,不要写进 src/
## 构建与验证
- 改完跑 `npm run check`(类型+lint+测试)
- dev server 端口 3000,不要改端口配置
## 红线
- 不要改数据库 migration 历史文件
- 不要动 auth/ 目录,涉及安全需人工审The return on this small investment is exceptional. It determines whether the AI behaves like an informed collaborator or an intern wandering through the codebase. This project's own .claude/CLAUDE.md offers one example.
Second, make sure the AI can verify its own work. Tell it exactly how to run the build, tests, and linter. An AI that can execute npm run check and validate its changes is dramatically more reliable than one that only writes code.
During Integration: Expand Permissions Gradually from Read-Only to Write Access
Do not begin with full repository write access and automatic command execution. A sensible progression looks like this:
- Read-only exploration: Have the AI read code and answer questions such as “Where is this feature implemented?” and “Why does this logic work this way?” This stage carries almost no risk and tests whether the model truly understands the project.
- Narrow write access with confirmation at every step: Give it one clearly bounded task, and approve each file edit and command. Watch whether it follows the rules and stays within scope.
- Broader access after trust is established: Once it has proved reliable, automatically approve low-risk actions such as reading files, running tests, and editing designated directories. Keep human confirmation for high-risk actions such as deleting files, changing configuration, installing dependencies, and performing Git operations.
All three tools offer permission and automatic-approval settings. Use them deliberately. Pair them with Git worktree isolation: let the AI work in a separate directory that can be discarded if something goes wrong, while the main workspace remains safe. This is one of the most important safeguards when introducing AI to an existing project.
Expand access in stages: read-only, then narrow writes with confirmation, then automatic approval for trusted low-risk actions—while high-risk work always requires confirmation.
Choosing Among the Three Tools
Their capabilities are converging quickly, but their interfaces and strengths still differ:
| Tool | Form | Strengths | Best For |
|---|---|---|---|
| Cursor | AI-native IDE built on VS Code | Smooth in-editor experience, inline completion, and visible edits | Developers who prefer an IDE and alternate frequently between human and AI coding |
| Claude Code | Terminal CLI with IDE integrations | Broad multifile tasks, autonomous agent-style execution, and complex project changes | Large refactors, multistep tasks, and scripted workflows |
| Codex | CLI and cloud agent | Background task delegation and cloud parallelism | Batch work and asynchronous delegation |
A practical rule is: choose Cursor when you want AI to help you write; choose Claude Code or Codex when you want to delegate a task for autonomous completion. Many teams use both styles—Cursor for everyday coding in the IDE and Claude Code for larger changes. The preparation required for an existing project is the same in every case: context files, permissions, and validation. The tool is simply the execution layer. For a more detailed combination strategy, see AI Coding Tool Combination Workflows.
Choosing the First Task
Do not use a core module as your test case after connecting an AI to an existing project. A good first task has a clear scope, low risk, explicit acceptance criteria, and a solution you could implement yourself. Examples include adding a missing unit test, fixing a known minor bug, or adding type annotations to one function.
Such tasks calibrate three things: whether the AI understands project conventions, the quality of its changes, and whether your permission and validation process works smoothly. Run two or three calibration tasks and learn how much you can trust the tool before giving it heavier work. Skipping calibration and sending AI straight into core business logic is one of the most common mistakes beginners make.
The first task is calibration, not production: confirm that the AI understands the project, produces trustworthy changes, and follows the workflow before increasing the stakes.
Common Pitfalls
- Skipping a context file and expecting the AI to “figure it out”: It will read the code, but it will miss every convention the code does not state and may replace project practices with generic best practices.
- Assigning too much at once: A request such as “refactor the entire order module” is easy for an AI to lose track of and difficult for a person to review. Break the work into small, verifiable, reversible steps.
- Merging without verification: When the AI says it has finished and all tests pass, confirm that the commands actually ran. See How to Review AI-Generated Code.
- Letting AI touch areas it should not: Migration history, secret configuration, CI pipelines, and authentication logic belong behind explicit red lines in the project-instructions file and require human review.
- Ignoring the context budget: Do not ask an AI to read dozens of files at once in a large project. Guide it to locate relevant files before reading them, or rely on the tool's code-search capabilities.
Who This Is For and Other Options
This approach is for developers who want to use AI coding tools in everyday work rather than stop at demos. If your “project” is genuinely new, you can simplify the preparation because there is no historical baggage. Tools that generate from scratch, such as v0, Bolt.new, and Lovable, may be faster. For any real project with existing code, however, none of the preparation described here is optional. The quality of the context you provide directly determines whether AI becomes an advantage or a burden.
Frequently Asked Questions
Q: What if the project is too large to fit in the AI's context? A: Do not expect it to load the entire project at once. Modern tools provide code search or indexing and retrieve relevant files as needed. Tell the AI to locate the implementation before editing, and include a project map that explains each directory's responsibility in the context file. That helps it find the right material quickly.
Q: How should a team share its AI configuration? A: Commit CLAUDE.md, .cursor/rules, or AGENTS.md to the repository so the entire team uses the same conventions. Every person's AI then follows the same rules, preventing the confusion of individually tuned setups.
Q: What should we do if code quality declines after integration? A: The problem usually lies in context or review rather than the tool itself. Add missing conventions to the context file, tighten the red lines, and strengthen review and CI checks. A tool is an amplifier: sound engineering practices let AI amplify efficiency, while weak practices let it amplify disorder.
Conclusion
Success in integrating AI into an existing project depends less on tool selection than on three preparations: write a strong project-context file so the AI knows the rules, expand permissions gradually and isolate work in a worktree to protect the codebase, and begin with low-risk calibration tasks to establish trust. With those foundations, Claude Code, Cursor, and Codex can all become genuine project collaborators. Without them, even the strongest tool is simply a troublemaker that writes tidy code.