Mechanism: Constraints — Stop the Agent From "Improving" the Wrong Things | Neural Nexus
Skip to content
Mechanisms of Vibe Coding
Mechanism: Constraints — Stop the Agent From "Improving" the Wrong Things
ByTeacHER
Jun 17, 2026
#core
Mechanisms of Vibe Coding featured image — Constraints (Core)Table of Contents
Toggle
Mechanism: Constraints<br>Part of Mechanisms of Vibe Coding · Core · Read first: Goal.<br>One-sentence definition<br>Constraints are explicit limits on what the agent may change, add, or assume — file boundaries, forbidden actions, and style rules — stated alongside the goal so helpfulness does not become scope creep.<br>The problem<br>You set a clear goal: fix the login redirect. The agent fixes it — and reformats twelve files, adds a utility library, renames a variable across the repo, and introduces a helper nothing calls yet. Each change sounds reasonable alone. Together they turn a twenty-line review into a merge you dread.<br>Models optimize for plausible completion. Without constraints, “fix the bug” becomes “improve the codebase.”<br>Symptoms:<br>New dependencies when the task did not need them<br>Diffs in directories you never mentioned<br>Invented APIs, config keys, or env vars<br>You spend the session rejecting changes instead of steering toward the goal<br>How it works<br>The goal says what done looks like; constraints say what is off limits .<br>A practical constraints block has three layers:<br>File boundaries — paths or globs the agent may edit (src/auth/ only).<br>Do-not list — actions to avoid (no new dependencies, no drive-by refactors).<br>Project facts — truths the agent should not “fix” (we use pnpm, not npm).<br>Goal (what done means)<br>Constraints (what must not change / happen)<br>Agent work ──► Diff review ──► Violation? ──yes──► revert or re-prompt<br>no<br>Verify goalConstraints are negative space : the solution shape includes what you refuse to let happen.<br>When to use it<br>Every edit session, especially agent or autonomous modes<br>Legacy code, monorepos, strict compatibility areas<br>After a session that went off the rails — prevent a repeat<br>Team repos where conventions beat model defaults<br>When not to use it<br>Early exploration with nothing to protect — add constraints before the first commit<br>When constraints block the only viable fix — widen the boundary deliberately<br>A wall of rules with no goal — loosen goal or boundary, not “more constraints”<br>Failure modes<br>Over-constraining — Agent cannot progress. Fix: Loosen file boundary; keep do-not list for deps and refactors.<br>Constraints without a goal — Rules with no outcome. Fix: Symptom + verify first (Goal).<br>Implicit conventions — “Everyone knows we don’t add lodash.” Fix: Put standing rules in project rules or the prompt.<br>Stale constraints — Old stack rules block a valid fix. Fix: Update when the goal changes.<br>Cosmetic freeze — “Don’t change anything” plus a feature request. Fix: Narrow file boundary instead.<br>Minimal example<br>Context: Same health endpoint as Goal. Team forbids new dependencies and cross-folder edits.<br>Steps:<br>Combine goal and constraints in one block:<br>Goal: GET /health returns { "ok": true } after startup completes.<br>Verify: pnpm test -- health.test.ts; curl shows "ok":true.
Constraints:<br>- Edit only src/health.ts and src/bootstrap.ts<br>- Do not add dependencies or new files<br>- Do not refactor unrelated modules or reformat other files<br>- Use existing config.ready; do not introduce a new config systemSend before any @ references or “go ahead.”<br>Reject diff hunks outside those files even if they look helpful.<br>Done when: Verify passes and every constraint line held.<br>Tool instances (optional deep-dive)<br>Portable idea above; tool-specific. Date: June 2026.
Cursor<br>Constraints in the first message with the goal, or in .cursor/rules every session.<br>Agent mode: constraints reduce violations — still review the diff.<br>.cursorignore hides paths the agent should not touch.<br>Re-prompt: “Violated [rule]. Revert X; fix only within [boundary].”<br>Other tools<br>CLAUDE.md, Aider CONVENTIONS.md, Copilot custom instructions — persistent constraints before edits.<br>Related mechanisms<br>Goal — defines done; constraints defend the path<br>Scope fence — one job per session; constraints define fence edges<br>Negative space — what not to touch, add, or refactor<br>Try it yourself<br>Exercise: Add five lines to your project rules: two file boundaries, two do-not actions, one project fact. Pair with a real goal.<br>Done when: A fresh agent chat would know what is forbidden without asking you.
By TeacHER<br>TeacHER is the Neural Nexus learning guide, explaining AI tools, concepts, and workflows in clear, practical language. Every TeacHER article is made to help visitors understand AI without hype and try something useful for themselves.
Related Post
Mechanisms of Vibe Coding
Mechanism: Pair Vibe — Human Steers, Agent Executes
Jun 17, 2026
TeacHER
Mechanisms of Vibe Coding
Mechanism: Confidence Calibration — When to Trust vs Re-Read Every Line
Jun 17, 2026
TeacHER
Mechanisms of Vibe Coding
Mechanism: Over-Automation Trap...