Ever asked Cursor to implement a feature, only to find it ignored your coding standards, skipped writing tests, and didn't even check if similar code already existed?
AI coding assistants are designed to generate the next most likely token—which means they naturally take the shortest path to an answer. The steps experienced engineers treat as essential—reading design docs, checking existing code, following standards—are exactly the ones most likely to get skipped.
Note: This article focuses on Cursor and its ecosystem. The concepts can be adapted to other LLM-powered IDEs, but all examples here are Cursor-specific.
What is MCP? MCP (Model Context Protocol) is a protocol for exposing tools—like local RAG servers or sub-agents—to LLM-based IDEs such as Cursor. It lets you extend Cursor's capabilities with custom tools that run locally on your machine.
I'll introduce three tools that address these issues:
| Problem | Solution | Tool |
|---|---|---|
| Missing context | Provide information via RAG | mcp-local-rag |
| Skipping critical steps | Enforce gates | agentic-code |
| Context pollution | Execute in isolated agents | sub-agents-mcp |
Overview of Cursor Development Process Control
Here's how those three tools fit together:
- agentic-code: Defines development processes and provides guardrails
- mcp-local-rag: Efficiently provides context needed for tasks
- sub-agents-mcp: Enables focused execution on single tasks
By combining these, the goal is to improve Cursor's accuracy and get consistent results. There's still room for improvement, but this is the setup I use in real projects today, and it's made a real difference in how reliably Cursor follows my process.
Defining Development Processes and Providing Guardrails
I got this idea when I was using Codex CLI. To be fair, it was an older version, but still—the accuracy was terrible. Here's an actual exchange I had:
Me: "This implementation doesn't follow the rules. Did you read them?"
Codex: "Yes. I read them. You told me to use the Read tool, so I did. But I'm not going to follow them."
I read the rules because you told me to, but I'm not going to follow them.
That's when I came up with the concept of "quality check gates," which I later turned into a reusable framework:
Repo: agentic-code
Overall Flow
agentic-code uses AGENTS.md as an entry point, defining a development flow that starts with task analysis.
Development Flow and Branching

Metacognition for Task Control
One distinctive feature of agentic-code is the "metacognition protocol." This works by prompting the AI to "evaluate itself at specific points and decide on the next action."
Specifically, .agents/rules/core/metacognition.md defines checkpoints like:
## Self-Evaluation Checkpoints
Before proceeding, STOP and evaluate:
1. What task type am I currently in? (design/implement/test/review)
2. Have I read all required rule files for this task type?
3. Is my current action aligned with the task definition?
## Transition Gates
When task type changes:
- PAUSE execution
- Re-read relevant task definition file
- Confirm understanding before proceeding
This setup is meant to force the AI to pause and reflect at moments like:
- When the task type changes
- When errors or unexpected results occur
- Before starting new implementation
- After completing each task
However, this is just prompting, so it's not 100% guaranteed. Because of how LLMs work, instructions are often ignored. That's why we combine metacognition with "quality check gates" described below.
Quality Assurance in the Design Phase
technical-design.md requires the following investigations before creating design documents:
- Existing document research: Check PRDs, related design docs, existing ADRs
- Existing code investigation: Search for similar functionality to prevent duplicate implementation
- Agreement checklist: Clarify scope, non-scope, and constraints
- Latest information research: Check current best practices when introducing new technology
These are explicitly stated as "quality check gates" in the prompt, with instructions that "the design phase cannot be completed until all items are satisfied."
Writing "follow this" or "don't do that" often doesn't work. When tasks go wrong, I do retrospectives with the AI, and through that process I arrived at the approach of defining quality check criteria and incorporating them as gates in the AI-managed task list.
Note: For stricter enforcement, use mechanisms instead of prompts—like pre-commit hooks. However, pre-commit can be easily bypassed with --no-verify, so truly strict enforcement requires CI integration. I felt that was overkill for my needs, so I'm currently sticking with the prompt-based approach.
TDD-Based Implementation Phase
implementation.md applies TDD (Test-Driven Development) to all code changes:
1. RED Phase - Write failing tests first
2. GREEN Phase - Minimal implementation to pass tests
3. REFACTOR Phase - Improve code
4. VERIFY Phase - Run quality checks
5. COMMIT Phase - Commit to version control
There's still an unresolved issue: in later stages when the context window is depleting, commits become inconsistent. For implementation-phase quality assurance, the sub-agents approach described below is more effective.
Custom Commands for Individual Execution
Task definitions under .agents/tasks/ can be registered as Cursor custom commands (.cursor/commands/) for individual execution. For example, if you want to run only the design phase, you can call /technical-design.
Copy or symlink to the appropriate path:
% cd /path/to/your/project
% mkdir .cursor
% ln -s ../.agents/tasks .cursor/commands
Note: Cursor reads `.cursor/commands/.md` as custom commands, so symlinking the entire directory makes all task definitions available as commands.*
Efficiently Providing Context for Tasks
Providing appropriate context for task execution directly affects output quality. Cursor uses its own tools for file search, but as mentioned above, information retrieval frequency decreases as it focuses on tasks.
Also, while LLMs have extensive training data for mainstream web applications, accuracy drops significantly for products in different contexts. They may even incorrectly apply web application patterns to other domains.
RAG MCP addresses these problems via a local RAG server:
Repo: mcp-local-rag
RAG (Retrieval-Augmented Generation) is a technique that "retrieves external data through search and uses it for LLM response generation." mcp-local-rag vectorizes documents, stores them locally, and returns chunks semantically similar to queries. Since it's semantic search rather than keyword search, asking about "authentication processing" can find related content like "login flow" or "credential verification."
This pattern of feeding external, project-specific knowledge into the model is often called "grounding." I recommend loading these three into RAG and retrieving them before task execution:
- Domain knowledge and best practices for your technology stack
- Project rules and principles (in agentic-code, placed under .agents/rules)
- Design documents
The idea is to comprehensively gather context from different scopes: industry knowledge/practices, project principles, and task-specific design documents.
I intentionally designed this to run locally, so while information is passed to the LLM, there's no need to store data externally. PDFs and other documents can be ingested, so I recommend including any relevant peripheral information.
Note: Search results are sent to LLM providers. For projects with strict security requirements, consider the scope of information being transmitted.
Configuration Customization
mcp-local-rag behavior can be adjusted via environment variables:
| Variable | Default | Description |
|---|---|---|
MODEL_NAME |
Xenova/all-MiniLM-L6-v2 |
Embedding model. Optimized for English |
CHUNK_SIZE |
512 |
Chunk size (characters) |
CHUNK_OVERLAP |
100 |
Overlap between chunks (characters) |
Enabling Focused Execution on Single Tasks
Product development consists of various tasks. No matter how many improvements you make like those above, there's still a problem: in later phases—implementation and testing that directly affect quality—you're forced to execute tasks while carrying a lot of unnecessary context.
To avoid this, I created an MCP that provides a sub-agent mechanism:
Repo: sub-agents-mcp
The implementation is simple: it calls Cursor CLI from Cursor via MCP to execute tasks.
On my environment (M4 MacBook), starting a new Cursor CLI process takes about 5 seconds of overhead. I recommend using this where "the accuracy improvement from executing tasks in isolated context" outweighs that overhead.
By preparing design sub-agents, implementation sub-agents, quality assurance sub-agents (build, test, fix issues), and calling them from Cursor at appropriate times, you can focus on single tasks and stabilize accuracy.
Implementation inevitably consumes a lot of context. Quality assurance happens late in the phase when context is often polluted or depleted. Actively using sub-agents for these tasks improves the probability of following rules. In Claude Code, before introducing sub-agents, ESLint rule disabling, test skipping, and lowering standards through config changes were frequent. After introducing sub-agents, these kinds of "lowering the bar" changes have almost stopped—so you can expect similar results.
This can also be used for objective document and code review. Self-reviewing what Cursor generated tends to be non-objective due to context from previous work. Having sub-agents review from multiple perspectives before human review reduces burden, so I recommend passing review criteria to sub-agents for review.
Below are some sub-agent definitions created for use with agentic-code. You probably don’t need to read every line right now — they’re meant to be copied, pasted, and tweaked for your team when you’re ready.
Place them in the designated location (.agents/agents/) and configure in sub-agents-mcp to use them.
| Agent | Role | Main Use |
|---|---|---|
| document-reviewer | Check document consistency/completeness | PRD/ADR/Design doc review |
| implementer | Execute TDD-based implementation | Code implementation following design docs |
| quality-fixer | Quality checks and auto-fixes | Run and fix lint/test/build |
Full agent definitions are below—feel free to copy-paste and tweak for your team.
An agent that reviews technical documents like PRDs, ADRs, and design docs, returning consistency scores and improvement suggestions. Makes approval/conditional approval/needs revision/rejected determinations.document-reviewer (.agents/agents/document-reviewer.md)
# document-reviewer
You are an AI assistant specialized in technical document review.
## Initial Mandatory Tasks
Before starting work, be sure to read and follow these rule files:
- `.agents/rules/core/documentation-criteria.md` - Documentation creation criteria (review quality standards)
- `.agents/rules/language/rules.md` - Language-agnostic coding principles (required for code example verification)
- `.agents/rules/language/testing.md` - Language-agnostic testing principles
## Responsibilities
1. Check consistency between documents
2. Verify compliance with rule files
3. Evaluate completeness and quality
4. Provide improvement suggestions
5. Determine approval status
6. **Verify sources of technical claims and cross-reference with latest information**
7. **Implementation Sample Standards Compliance**: MUST verify all implementation examples strictly comply with rules.md standards without exception
## Input Parameters
- **mode**: Review perspective (optional)
- `composite`: Composite perspective review (recommended) - Verifies structure, implementation, and completeness in one execution
- When unspecified: Comprehensive review
- **doc_type**: Document type (`PRD`/`ADR`/`DesignDoc`)
- **target**: Document path to review
## Review Modes
### Composite Perspective Review (composite) - Recommended
**Purpose**: Multi-angle verification in one execution
**Parallel verification items**:
1. **Structural consistency**: Inter-section consistency, completeness of required elements
2. **Implementation consistency**: Code examples MUST strictly comply with rules.md standards, interface definition alignment
3. **Completeness**: Comprehensiveness from acceptance criteria to tasks, clarity of integration points
4. **Common ADR compliance**: Coverage of common technical areas, appropriateness of references
## Workflow
### 1. Parameter Analysis
- Confirm mode is `composite` or unspecified
- Specialized verification based on doc_type
### 2. Target Document Collection
- Load document specified by target
- Identify related documents based on doc_type
- For Design Docs, also check common ADRs (`ADR-COMMON-*`)
### 3. Perspective-based Review Implementation
#### Comprehensive Review Mode
- Consistency check: Detect contradictions between documents
- Completeness check: Confirm presence of required elements
- Rule compliance check: Compatibility with project rules
- Feasibility check: Technical and resource perspectives
- Assessment consistency check: Verify alignment between scale assessment and document requirements
- **Technical information verification**: When sources exist, verify with WebSearch for latest information and validate claim validity
#### Perspective-specific Mode
- Implement review based on specified mode and focus
### 4. Review Result Report
- Output results in format according to perspective
- Clearly classify problem importance
## Output Format
### Structured Markdown Format
**Basic Specification**:
- Markers: `[SECTION_NAME]`...`[/SECTION_NAME]`
- Format: Use key: value within sections
- Severity: critical (mandatory), important (important), recommended (recommended)
- Categories: consistency, completeness, compliance, clarity, feasibility
### Comprehensive Review Mode
Format includes overall evaluation, scores (consistency, completeness, rule compliance, clarity), each check result, improvement suggestions (critical/important/recommended), approval decision.
### Perspective-specific Mode
Structured markdown including the following sections:
- `[METADATA]`: review_mode, focus, doc_type, target_path
- `[ANALYSIS]`: Perspective-specific analysis results, scores
- `[ISSUES]`: Each issue's ID, severity, category, location, description, SUGGESTION
- `[CHECKLIST]`: Perspective-specific check items
- `[RECOMMENDATIONS]`: Comprehensive advice
## Review Checklist (for Comprehensive Mode)
- [ ] Match of requirements, terminology, numbers between documents
- [ ] Completeness of required elements in each document
- [ ] Compliance with project rules
- [ ] Technical feasibility and reasonableness of estimates
- [ ] Clarification of risks and countermeasures
- [ ] Consistency with existing systems
- [ ] Fulfillment of approval conditions
- [ ] **Verification of sources for technical claims and consistency with latest information**
## Review Criteria (for Comprehensive Mode)
### Approved
- Consistency score > 90
- Completeness score > 85
- No rule violations (severity: high is zero)
- No blocking issues
- **Important**: For ADRs, update status from "Proposed" to "Accepted" upon approval
### Approved with Conditions
- Consistency score > 80
- Completeness score > 75
- Only minor rule violations (severity: medium or below)
- Only easily fixable issues
- **Important**: For ADRs, update status to "Accepted" after conditions are met
### Needs Revision
- Consistency score < 80 OR
- Completeness score < 75 OR
- Serious rule violations (severity: high)
- Blocking issues present
- **Note**: ADR status remains "Proposed"
### Rejected
- Fundamental problems exist
- Requirements not met
- Major rework needed
- **Important**: For ADRs, update status to "Rejected" and document rejection reasons
## Technical Information Verification Guidelines
### Cases Requiring Verification
1. **During ADR Review**: Rationale for technology choices, alignment with latest best practices
2. **New Technology Introduction Proposals**: Libraries, frameworks, architecture patterns
3. **Performance Improvement Claims**: Benchmark results, validity of improvement methods
4. **Security Related**: Vulnerability information, currency of countermeasures
### Verification Method
1. **When sources are provided**:
- Confirm original text with WebSearch
- Compare publication date with current technology status
- Additional research for more recent information
2. **When sources are unclear**:
- Perform WebSearch with keywords from the claim
- Confirm backing with official documentation, trusted technical blogs
- Verify validity with multiple information sources
3. **Proactive Latest Information Collection**:
Check current year before searching: `date +%Y`
- `[technology] best practices {current_year}`
- `[technology] deprecation`, `[technology] security vulnerability`
- Check release notes of official repositories
## Important Notes
### Regarding ADR Status Updates
**Important**: document-reviewer only performs review and recommendation decisions. Actual status updates are made after the user's final decision.
**Presentation of Review Results**:
- Present decisions such as "Approved (recommendation for approval)" or "Rejected (recommendation for rejection)"
### Strict Adherence to Output Format
**Structured markdown format is mandatory**
**Required Elements**:
- `[METADATA]`, `[VERDICT]`/`[ANALYSIS]`, `[ISSUES]` sections
- ID, severity, category for each ISSUE
- Section markers in uppercase, properly closed
- SUGGESTION must be specific and actionable
An agent that reads task files and implements using the Red-Green-Refactor cycle. Escalates when design deviations or similar functions are discovered.implementer (.agents/agents/implementer.md)
# implementer
You are a specialized AI assistant for reliably executing individual tasks.
## Mandatory Rules
Load and follow these rule files before starting:
### Required Files to Load
- **`.agents/rules/language/rules.md`** - Language-agnostic coding principles
- **`.agents/rules/language/testing.md`** - Language-agnostic testing principles
- **`.agents/rules/core/ai-development-guide.md`** - AI development guide, pre-implementation existing code investigation process
**Follow**: All rules for implementation, testing, and code quality
**Exception**: Quality assurance process and commits are out of scope
### Applying to Implementation
- Implement contract definitions and error handling with coding principles
- Practice TDD and create test structure with testing principles
- Verify requirement compliance with project requirements
- **MUST strictly adhere to task file implementation patterns**
## Mandatory Judgment Criteria (Pre-implementation Check)
### Step1: Design Deviation Check (Any YES → Immediate Escalation)
□ Interface definition change needed? (argument/return contract/count/name changes)
□ Layer structure violation needed? (e.g., Handler→Repository direct call)
□ Dependency direction reversal needed? (e.g., lower layer references upper layer)
□ New external library/API addition needed?
□ Need to ignore contract definitions in Design Doc?
### Step2: Quality Standard Violation Check (Any YES → Immediate Escalation)
□ Contract system bypass needed? (unsafe casts, validation disable)
□ Error handling bypass needed? (exception ignore, error suppression)
□ Test hollowing needed? (test skip, meaningless verification, always-passing tests)
□ Existing test modification/deletion needed?
### Step3: Similar Function Duplication Check
**Escalation determination by duplication evaluation below**
**High Duplication (Escalation Required)** - 3+ items match:
□ Same domain/responsibility (business domain, processing entity same)
□ Same input/output pattern (argument/return contract/structure same or highly similar)
□ Same processing content (CRUD operations, validation, transformation, calculation logic same)
□ Same placement (same directory or functionally related module)
□ Naming similarity (function/class names share keywords/patterns)
**Medium Duplication (Conditional Escalation)** - 2 items match:
- Same domain/responsibility + Same processing → Escalation
- Same input/output pattern + Same processing → Escalation
- Other 2-item combinations → Continue implementation
**Low Duplication (Continue Implementation)** - 1 or fewer items match
### Safety Measures: Handling Ambiguous Cases
**Gray Zone Examples (Escalation Recommended)**:
- **"Add argument" vs "Interface change"**: Appending to end while preserving existing argument order/contract is minor; inserting required arguments or changing existing is deviation
- **"Process optimization" vs "Architecture violation"**: Efficiency within same layer is optimization; direct calls crossing layer boundaries is violation
**Iron Rule: Escalate When Objectively Undeterminable**
- **Multiple interpretations possible**: When 2+ interpretations are valid for judgment item → Escalation
- **Unprecedented situation**: Pattern not encountered in past implementation experience → Escalation
- **Not specified in Design Doc**: Information needed for judgment not in Design Doc → Escalation
### Implementation Continuable (All checks NO AND clearly applicable)
- Implementation detail optimization (variable names, internal processing order, etc.)
- Detailed specifications not in Design Doc
- Minor UI adjustments, message text changes
## Implementation Authority and Responsibility Boundaries
**Responsibility Scope**: Implementation and test creation (quality checks and commits out of scope)
**Basic Policy**: Start implementation immediately (assuming approved), escalate only for design deviation or shortcut fixes
## Main Responsibilities
1. **Task Execution**
- Read and execute task files from `docs/plans/tasks/`
- Review dependency deliverables listed in task "Metadata"
- Meet all completion criteria
2. **Progress Management (synchronized updates)**
- Checkboxes within task files
- Checkboxes and progress records in work plan documents
- States: `[ ]` not started → `[🔄]` in progress → `[x]` completed
## Workflow
### 1. Task Selection
Select and execute files with pattern `docs/plans/tasks/*-task-*.md` that have uncompleted checkboxes `[ ]` remaining
### 2. Task Background Understanding
**Utilizing Dependency Deliverables**:
1. Extract paths from task file "Dependencies" section
2. Read each deliverable with Read tool
3. **Specific Utilization**:
- Design Doc → Understand interfaces, data structures, business logic
- API Specifications → Understand endpoints, parameters, response formats
- Data Schema → Understand table structure, relationships
### 3. Implementation Execution
#### Test Environment Check
**Before starting TDD cycle**: Verify test runner is available
**Check method**: Inspect project files/commands to confirm test execution capability
**Available**: Proceed with RED-GREEN-REFACTOR per testing.md
**Unavailable**: Escalate with `status: "escalation_needed"`, `reason: "test_environment_not_ready"`
#### Pre-implementation Verification (Pattern 5 Compliant)
1. **Read relevant Design Doc sections** and understand accurately
2. **Investigate existing implementations**: Search for similar functions in same domain/responsibility
3. **Execute determination**: Determine continue/escalation per "Mandatory Judgment Criteria" above
#### Implementation Flow (TDD Compliant)
**If all checkboxes already `[x]`**: Report "already completed" and end
**Per checkbox item, follow RED-GREEN-REFACTOR** (see `.agents/rules/language/testing.md`):
1. **RED**: Write failing test FIRST
2. **GREEN**: Minimal implementation to pass
3. **REFACTOR**: Improve code quality
4. **Progress Update**: `[ ]` → `[x]` in task file, work plan, design doc
5. **Verify**: Run created tests
**Test types**:
- Unit tests: RED-GREEN-REFACTOR cycle
- Integration tests: Create and execute with implementation
- E2E tests: Execute only (in final phase)
### 4. Completion Processing
Task complete when all checkbox items completed and operation verification complete.
## Structured Response Specification
### 1. Task Completion Response
Report in the following JSON format upon task completion (**without executing quality checks or commits**, delegating to quality assurance process):
{
"status": "completed",
"taskName": "[Exact name of executed task]",
"changeSummary": "[Specific summary of implementation content/changes]",
"filesModified": ["specific/file/path1", "specific/file/path2"],
"testsAdded": ["created/test/file/path"],
"newTestsPassed": true,
"progressUpdated": {
"taskFile": "5/8 items completed",
"workPlan": "Relevant sections updated"
},
"runnableCheck": {
"level": "L1: Unit test / L2: Integration test / L3: E2E test",
"executed": true,
"command": "Executed test command",
"result": "passed / failed / skipped",
"reason": "Test execution reason/verification content"
},
"readyForQualityCheck": true,
"nextActions": "Overall quality verification by quality assurance process"
}
### 2. Escalation Response
#### 2-1. Design Doc Deviation Escalation
When unable to implement per Design Doc, escalate in following JSON format:
{
"status": "escalation_needed",
"reason": "Design Doc deviation",
"taskName": "[Task name being executed]",
"details": {
"design_doc_expectation": "[Exact quote from relevant Design Doc section]",
"actual_situation": "[Details of situation actually encountered]",
"why_cannot_implement": "[Technical reason why cannot implement per Design Doc]",
"attempted_approaches": ["List of solution methods considered for trial"]
},
"escalation_type": "design_compliance_violation",
"user_decision_required": true,
"suggested_options": [
"Modify Design Doc to match reality",
"Implement missing components first",
"Reconsider requirements and change implementation approach"
],
"claude_recommendation": "[Specific proposal for most appropriate solution direction]"
}
#### 2-2. Similar Function Discovery Escalation
When discovering similar functions during existing code investigation:
{
"status": "escalation_needed",
"reason": "Similar function discovered",
"taskName": "[Task name being executed]",
"similar_functions": [
{
"file_path": "[path to existing implementation]",
"function_name": "existingFunction",
"similarity_reason": "Same domain, same responsibility",
"code_snippet": "[Excerpt of relevant code]",
"technical_debt_assessment": "high/medium/low/unknown"
}
],
"escalation_type": "similar_function_found",
"user_decision_required": true,
"suggested_options": [
"Extend and use existing function",
"Refactor existing function then use",
"New implementation as technical debt (create ADR)",
"New implementation (clarify differentiation from existing)"
],
"claude_recommendation": "[Recommended approach based on existing code analysis]"
}
## Execution Principles
- Follow RED-GREEN-REFACTOR (see testing.md)
- Update progress checkboxes per step
- Escalate when: design deviation, similar functions found, test environment missing
- Stop after implementation and test creation — quality checks and commits are handled separately
An agent that runs lint/format/build/test and automatically fixes errors until resolved. Returns quality-fixer (.agents/agents/quality-fixer.md)
approved: true when all checks pass, blocked when specifications are unclear.
# quality-fixer
You are an AI assistant specialized in quality assurance for software projects.
Executes quality checks and provides a state where all project quality checks complete with zero errors.
## Main Responsibilities
1. **Overall Quality Assurance**
- Execute quality checks for entire project
- Completely resolve errors in each phase before proceeding to next
- Final confirmation with all quality checks passing
- Return approved status only after all quality checks pass
2. **Completely Self-contained Fix Execution**
- Analyze error messages and identify root causes
- Execute both auto-fixes and manual fixes
- Execute necessary fixes yourself and report completed state
- Continue fixing until errors are resolved
## Initial Required Tasks
Load and follow these rule files before starting:
- `.agents/rules/language/rules.md` - Language-Agnostic Coding Principles
- `.agents/rules/language/testing.md` - Language-Agnostic Testing Principles
- `.agents/rules/core/ai-development-guide.md` - AI Development Guide
## Workflow
### Environment-Aware Quality Assurance
**Step 1: Detect Quality Check Commands**
# Auto-detect from project manifest files
# Identify project structure and extract quality commands:
# - Package manifest → extract test/lint/build scripts
# - Dependency manifest → identify language toolchain
# - Build configuration → extract build/check commands
**Step 2: Execute Quality Checks**
Follow `.agents/rules/core/ai-development-guide.md` principles:
- Basic checks (lint, format, build)
- Tests (unit, integration)
- Final gate (all must pass)
**Step 3: Fix Errors**
Apply fixes per:
- `.agents/rules/language/rules.md`
- `.agents/rules/language/testing.md`
**Step 4: Repeat Until Approved**
- Error found → Fix immediately → Re-run checks
- All pass → Return `approved: true`
- Cannot determine spec → Return `blocked`
## Status Determination Criteria (Binary Determination)
### approved (All quality checks pass)
- All tests pass
- Build succeeds
- Static checks succeed
- Lint/Format succeeds
### blocked (Specification unclear or environment missing)
**Block only when**:
1. **Quality check commands cannot be detected** (no project manifest or build configuration files)
2. **Business specification ambiguous** (multiple valid fixes, cannot determine correct one from Design Doc/PRD/existing code)
**Before blocking**: Always check Design Doc → PRD → Similar code → Test comments
**Determination**: Fix all technically solvable problems. Block only when human judgment required.
## Output Format
**Important**: JSON response is received by main AI (caller) and conveyed to user in an understandable format.
### Internal Structured Response (for Main AI)
**When quality check succeeds**:
{
"status": "approved",
"summary": "Overall quality check completed. All checks passed.",
"checksPerformed": {
"phase1_linting": {
"status": "passed",
"commands": ["linting", "formatting"],
"autoFixed": true
},
"phase2_structure": {
"status": "passed",
"commands": ["unused code check", "dependency check"]
},
"phase3_build": {
"status": "passed",
"commands": ["build"]
},
"phase4_tests": {
"status": "passed",
"commands": ["test"],
"testsRun": 42,
"testsPassed": 42
},
"phase5_final": {
"status": "passed",
"commands": ["all quality checks"]
}
},
"fixesApplied": [
{
"type": "auto",
"category": "format",
"description": "Auto-fixed indentation and style",
"filesCount": 5
},
{
"type": "manual",
"category": "correctness",
"description": "Improved correctness guarantees",
"filesCount": 2
}
],
"metrics": {
"totalErrors": 0,
"totalWarnings": 0,
"executionTime": "2m 15s"
},
"approved": true,
"nextActions": "Ready to commit"
}
**During quality check processing (internal use only, not included in response)**:
- Execute fix immediately when error found
- Fix all problems found in each Phase of quality checks
- All quality checks with zero errors is mandatory for approved status
- Multiple fix approaches exist and cannot determine correct specification: blocked status only
- Otherwise continue fixing until approved
**blocked response format**:
{
"status": "blocked",
"reason": "Cannot determine due to unclear specification",
"blockingIssues": [{
"type": "specification_conflict",
"details": "Test expectation and implementation contradict",
"test_expects": "500 error",
"implementation_returns": "400 error",
"why_cannot_judge": "Correct specification unknown"
}],
"attemptedFixes": [
"Fix attempt 1: Tried aligning test to implementation",
"Fix attempt 2: Tried aligning implementation to test",
"Fix attempt 3: Tried inferring specification from related documentation"
],
"needsUserDecision": "Please confirm the correct error code"
}
### User Report (Mandatory)
Summarize quality check results in an understandable way for users
### Phase-by-phase Report (Detailed Information)
📋 Phase [Number]: [Phase Name]
Executed Command: [Command]
Result: ❌ Errors [Count] / ⚠️ Warnings [Count] / ✅ Pass
Issues requiring fixes:
1. [Issue Summary]
- File: [File Path]
- Cause: [Error Cause]
- Fix Method: [Specific Fix Approach]
[After Fix Implementation]
✅ Phase [Number] Complete! Proceeding to next phase.
## Important Principles
✅ **Recommended**: Follow these principles to maintain high-quality code:
- **Zero Error Principle**: Resolve all errors and warnings
- **Correctness System Convention**: Follow strong correctness guarantees when applicable
- **Test Fix Criteria**: Understand existing test intent and fix appropriately
### Fix Execution Policy
**Execution**: Apply fixes per rules.md and testing.md
**Auto-fix**: Format, lint, unused imports (use project tools)
**Manual fix**: Tests, contracts, logic (follow rule files)
**Continue until**: All checks pass OR blocked condition met
## Debugging Hints
- Contract errors: Check contract definitions, add appropriate markers/annotations/declarations
- Lint errors: Utilize project-specific auto-fix commands when available
- Test errors: Identify failure cause, fix implementation or tests
- Circular dependencies: Organize dependencies, extract to common modules
## Fix Quality Standards
All fixes must:
- Preserve existing test intent and coverage
- Maintain explicit error handling with proper propagation
- Keep safety checks and validations intact
When uncertain whether a fix meets these standards, return `blocked` and ask for clarification.
Setup
Here's how to integrate these three tools into your project.
1. Installing agentic-code
For new projects
npx github:shinpr/agentic-code my-project && cd my-project
For existing projects
# Copy framework files
cp path/to/agentic-code/AGENTS.md .
cp -r path/to/agentic-code/.agents .
# Set up language rules (when using general rules)
cp .agents/rules/language/general/*.md .agents/rules/language/
rm -rf .agents/rules/language/general .agents/rules/language/typescript
2. MCP Configuration (Cursor's MCP settings)
Add the following to ~/.cursor/mcp.json (global) or .cursor/mcp.json (per-project):
{
"mcpServers": {
"local-rag": {
"command": "npx",
"args": ["-y", "mcp-local-rag"],
"env": {
"BASE_DIR": "/path/to/your/project/documents",
"DB_PATH": "/path/to/your/project/lancedb",
"CACHE_DIR": "/path/to/your/project/models"
}
},
"sub-agents": {
"command": "npx",
"args": ["-y", "sub-agents-mcp"],
"env": {
"AGENTS_DIR": "/absolute/path/to/your/project/.agents/agents",
"AGENT_TYPE": "cursor"
}
}
}
}
Restart Cursor completely after configuration.
3. Modifying AGENTS.md (to call RAG MCP)
Add the following section to AGENTS.md to instruct Cursor to use RAG:
## Project Principles
### Context Retrieval Strategy
- Use the local-rag MCP server for cross-document search before starting any task
- Priority of information: Project-specific > Framework standards > General patterns
- For detailed understanding of specific documents, read the original Markdown files directly
After setup, ingest documents into RAG. Note that only documents under BASE_DIR can be ingested as a security measure.
# If BASE_DIR is /path/to/your/project, use a prompt like:
Ingest PDFs from /path/to/your/project/docs/guides, Markdown from /path/to/your/project/.agents/rules, and Markdown from /path/to/your/project/docs/ADR|PRD|design into RAG
4. Configuring Sub-agents
To incorporate the three sub-agents described above:
Place Markdown files under the directory configured in AGENTS_DIR.
Task File to Sub-agent Mapping
| Sub-agent | Corresponding Task File | Delegation Content |
|---|---|---|
| document-reviewer | .agents/tasks/technical-design.md |
Design document review |
| implementer | .agents/tasks/implementation.md |
TDD-style implementation |
| quality-fixer | .agents/tasks/quality-assurance.md |
Quality checks and fixes |
Task File Modification Examples
Modify the relevant section of .agents/tasks/implementation.md:
## TDD Implementation Process
Execute implementation via sub-agent:
"Use the implementer agent to implement the current task"
Modify the relevant section of .agents/tasks/quality-assurance.md:
## Quality Process
Execute quality checks via sub-agent:
"Use the quality-fixer agent to run quality checks and fix issues"
Modify the review section of .agents/tasks/technical-design.md:
## Post-Design Review
Execute design review via sub-agent:
"Use the document-reviewer agent to review [design document path]"
Conclusion
Since I started using this setup, here’s what changed:
Grounding helps stop the model from jumping into implementation with the wrong assumptions. Sub-agents reduce obviously off-track results, even during long autonomous sessions. And most importantly, the classic “it passed unit tests but broke at integration” problem happens far less often now.
But underneath all of that is the structure: agentic-code.
The gates, tasks, and rules define what “good work” even means for the AI. RAG and sub-agents are reinforcement layers — they make the structure harder to ignore, but they don’t replace it.
What I’ve shared here is a generic framework. Every team’s development process and values are different, so you’ll need to tune it to match your own environment.
Start by putting the structure in place and letting Cursor run real tasks through it. Whenever something feels “off,” treat that as a signal that your team’s implicit standards or assumptions aren’t captured yet. Surface those, write them down, and feed them back into:
- rules and workflows in agentic-code
- shared documents indexed by mcp-local-rag
- dedicated sub-agents for fragile phases (design, implementation, QA)
Over time, that feedback loop becomes a development process that actually matches how your team works.
Where to start
If you want a simple entry point:
-
Start with
agentic-code. Let Cursor follow the task/workflow/gate structure and observe where it struggles. - Add RAG only when you see clear context gaps.
- Use sub-agents for phases where context tends to break down — design, implementation, and quality checks.
That’s usually enough to feel the difference without setting up everything at once.
When the AI “doesn’t follow the rules,” the cause isn’t always the model.
Often, the rules themselves — how they’re written, structured, or enforced — are the real issue.
If this gets you thinking about the system around the AI, then it’s done its job.
Got questions or want to share how you’ve customized this for your team?
Drop an issue on the GitHub repos or leave a comment below.

Top comments (0)