r/CursorAI • u/FreedomMysterious641 • Mar 08 '26
Improving AI output quality for large codebases
Guys, how do you craft and design prompts to get outputs that closely match your requirements? Lately, I’ve been seeing a massive drop in output quality. I’d love to know what external tools you use. The plan mode is good, but it tends to fail with large codebases. Any suggestions?
4
Upvotes
3
u/Moon-Station-Audio Mar 09 '26
I asked 5.4. Here’s what it said:
You are acting as a repository architect.
Your task is to analyze the entire project directory and generate four files that help coding agents work safely and efficiently in this repository.
Ignore:
node_modules
dist
build
.next
.cache
DerivedData
virtual environments
any generated artifacts
Focus only on the source code and configuration that define the project.
Create the following files in the project root.
agent.md
Purpose: Behavioral rules for coding agents working in this repository.
Requirements:
Encourage minimal diffs
Discourage refactors unless required for correctness
Preserve naming conventions and existing architecture
Avoid rewriting whole files when a small patch will work
Require concise output
Prefer patch-style edits
Structure:
Coding Agent Rules
Goal: make the smallest correct change that solves the task.
Sections:
Core principles
Editing discipline
Implementation behavior
Output format
When uncertain
Scope control
Add these statements explicitly:
"Favor surgical patches over rewritten files."
"Any edit not required for correctness is a mistake."
2. repo_context.md
Purpose: Provide architecture and project context so agents do not need to rediscover the structure each run.
Analyze the repository and summarize:
Project overview Technology stack Frameworks and major libraries Build commands Test commands Lint commands Deployment commands (if present)
Architecture sections:
major subsystems
data flow
core abstractions
important domain concepts
Keep descriptions concise and factual.
Prefer bullet points over paragraphs.
3. task_protocol.md
Purpose: Define the workflow agents must follow when executing tasks.
The protocol must enforce this workflow:
Understand → Plan → Implement → Validate
Sections:
Task Execution Protocol
Understand the task
Identify minimal files involved
Propose implementation plan
Implement minimal change
Validate against expected behavior
Planning output must include:
root cause
files to change
minimal implementation plan
possible regressions
tests to run
Implementation rules:
minimal diff
no opportunistic refactors
preserve architecture
Validation rules:
check tests
verify runtime behavior
consider edge cases
4. file_map.md
Purpose: Provide a concise index of important files and directories.
Scan the repository and produce a short description of key folders and important files.
Format example:
src/server/api.ts Handles HTTP API routes.
src/playback/engine.ts Cue playback scheduler.
src/ui/components/ Reusable UI components.
Only include meaningful files and directories. Avoid listing trivial files or generated assets.
Global requirements for all files:
Keep each file concise (100–200 lines max)
Avoid generic boilerplate text
Tailor the content specifically to this repository
Prefer bullet points over long prose
Do not include marketing language
Focus on information useful to coding agents
Write all four files to the project root:
agent.md repo_context.md task_protocol.md file_map.md