DEV Community

Cover image for How to Make Agents "think" Like a Maintainer
Mike Vardy
Mike Vardy

Posted on

How to Make Agents "think" Like a Maintainer


Cover Photo by Pexels from Pixabay

AI coding assistants are fast. They can clear your backlog before lunch—and today's LLM tools are are way more than autocomplete.

But speed alone isn’t the win—because LLMs default to the quickest path, not the right one.

They don’t see your architecture. They don’t remember past outages. They don’t know you’re trying to sunset that legacy service. So they generate code that works… but quietly chips away at your standards.

Role-play fixes that.

When you frame the AI as a Principal Engineer, you’re giving it a persona and mindset: question shortcuts, enforce patterns, protect the long-term. Suddenly it’s not acting like a supercharged intern—it’s acting like someone who’s accountable for the health of the system.


Four Principles of AI Code Governance

1. Role Definition

Define your AI's responsibility explicitly.

❌ Not this:
"You are a helpful AI assistant."

✅ This:
"You are a Principal Engineer responsible for enforcing 
architectural boundaries, blocking anti-patterns, and 
maintaining code quality standards."
Enter fullscreen mode Exit fullscreen mode

Try this now:

## Role
You are the Tech Lead. Your job is to:
- Enforce domain-driven design boundaries
- Reject code that violates team standards
- Question requests that introduce technical debt
Enter fullscreen mode Exit fullscreen mode

2. Negative Constraints

The most powerful rules say "NO":

⚠️ Never use any in TypeScript

⚠️ Core modules cannot import UI code

⚠️ No console.log in production

These constraints prevent drift into bad habits.

3. Context Scoping

Don't dump your entire rulebook into every request.

Approach Impact
Bad 500-line .cursorrules file loaded for every file
Good Architectural rules only for src/core/**/*.ts

This keeps AI focused and prevents context overload.

4. Safety Barriers

Make it impossible to ship broken code:

  • ✅ Require tests to pass
  • ✅ Run linters automatically
  • ✅ Block destructive commands
  • ✅ Enforce code review protocols

Tool Comparison: Choose Your Weapon

Tool Best For Key Feature Use When
Cursor Architecture enforcement File-pattern scoped rules You need surgical precision on specific file types
Windsurf Continuous governance Cascade engine You want persistent rule enforcement
Warp Terminal operations Folder-scoped agents You have a monorepo with different contexts
Claude Code Self-correction Post-execution hooks You want automated fix loops
Gemini Cloud environments Layered constraints You're working in cloud-native setups
Copilot Path-specific rules Directory targeting You need GitHub integration

Tool-by-Tool Implementation Guide

Cursor: Surgical Precision with MDC Rules

Click to expand Cursor setup

TL;DR: Enforce architecture boundaries only where they matter.

Quick setup:

mkdir -p .cursor/rules
Enter fullscreen mode Exit fullscreen mode

Create: .cursor/rules/architecture.mdc

description: DDD boundaries
globs: src/core/**/*.ts
alwaysApply: false

## FORBIDDEN
`src/core` cannot import from `src/ui`

## REQUIRED
All I/O uses `src/core/ports` interfaces

## Protocol
Reject violations. Explain why.
Enter fullscreen mode Exit fullscreen mode

Why this works: Rules activate only for relevant files—no context pollution.

Official Cursor Rules Docs


Windsurf: Continuous Governance

Click to expand Windsurf setup

TL;DR: Cascade rules across your entire codebase.

Create: .windsurfrules

<role>
  Maintainer. Readability over cleverness.
</role>

<security>
  ⚠️ NEVER output secrets
  ✅ ALWAYS validate with Zod
</security>

<style>
  - Use `pnpm`
  - Composition > inheritance
</style>
Enter fullscreen mode Exit fullscreen mode

💡 Pro tip: Add .codeiumignore to hide legacy code. AI learns from what it sees—don't let it learn from old mistakes.

Windsurf Cascade Docs


Warp: Folder-Scoped Terminal Agents

Click to expand Warp setup

TL;DR: Different AI behaviors per directory in monorepos.

Setup:

  • ops/WARP.md → DevOps persona
  • frontend/WARP.md → UI persona

Safety example:

# ops/WARP.md

⚠️ If user requests deployment commands:
DO NOT generate them.
Suggest `safe_deploy` workflow instead.
Enter fullscreen mode Exit fullscreen mode

This prevents dangerous one-off CLI instructions.

📖 Warp AI Docs


Claude Code: Self-Correcting Loops

Click to expand Claude Code setup

TL;DR: AI sees linting errors and fixes them automatically.

Create: .claude/settings.json

{
  "hooks": [
    {
      "type": "postToolUse",
      "command": "eslint --fix"
    },
    {
      "type": "postToolUse",
      "command": "npm test"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

The magic: Claude reads test output and self-corrects. No human needed.

Quick start: Run claude /init for repo-specific baseline.

📖 Claude Code Hooks Reference


Gemini Code Assist: Layered Cloud Constraints

Click to expand Gemini setup

TL;DR: Global + local rules prevent context rot.

Structure:

  • ~/.gemini/GEMINI.md → Universal style
  • ./GEMINI.md → Project constraints

Security:

"coreTools": ["ls", "grep", "cat"]
Enter fullscreen mode Exit fullscreen mode

💡 Pro tip: Limit tool access in cloud environments.


GitHub Copilot: Path-Specific Safety

Click to expand Copilot setup

TL;DR: Isolate high-risk areas with targeted rules.

Create: .github/instructions/migrations.instructions.md

applyTo: "db/migrations/**/*.sql"

## Migration Safety
⚠️ Every migration needs down-migration
⚠️ NEVER `DROP TABLE` without backup
✅ Create indices CONCURRENTLY
Enter fullscreen mode Exit fullscreen mode

📖 Copilot Custom Instructions


The Unified Approach: One Config to Rule Them All

Problem: Managing six config files is tedious.

Solution: Create a single AGENTS.md and symlink it everywhere.

touch AGENTS.md
ln -sf AGENTS.md .cursorrules
ln -sf AGENTS.md WARP.md
ln -sf AGENTS.md CLAUDE.md
ln -sf AGENTS.md GEMINI.md
Enter fullscreen mode Exit fullscreen mode

💡 For Cursor MDC: Reference with @AGENTS.md

Result: ✨ Every AI tool follows identical standards. One source of truth.


Your 3-Step Action Plan

Step 1: Add One Negative Constraint ⏱️ 5 minutes

Pick your biggest pain point from last code review:

## Constraints
⚠️ NEVER use `console.log` in production code
Enter fullscreen mode Exit fullscreen mode

Step 2: Enable CI Hooks for One Directory ⏱️ 15 minutes

{
  "hooks": [{
    "type": "postToolUse",
    "command": "eslint --fix src/core"
  }]
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Create Unified AGENTS.md ⏱️ 20 minutes

# AI Agent Configuration

## Role
Principal Engineer enforcing team standards

## Security
- NEVER output secrets
- ALWAYS validate inputs

## Architecture
- Core cannot import UI
- Use repository pattern

## Style
- Functional over class-based
- TypeScript strict mode
Enter fullscreen mode Exit fullscreen mode

Symlink everywhere. Done. ✅


💡 The Bottom Line

Unconfigured AI = Fast but reckless

Configured AI = Fast and reliable

The difference? A few well-crafted configuration files.

Start Today:

  1. ✅ Add one "NEVER" rule
  2. ✅ Watch errors caught earlier
  3. ✅ Enjoy quieter code reviews

Stop letting AI write bugs. Give it a job description and make it role play. Make it accountable.


📚 Additional Resources


Top comments (0)