Practical Rules for AI Coding Assistants: From Minimal Constraints to Reliable Delivery
This article explains how to design reusable rules for AI coding assistants: a minimal base of project facts, change boundaries, verification standards, and uncertainty handling; how to separate facts from behavioral constraints and engineering controls; templates for global and scoped rules; risk-based workflows; honest testing; and how to maintain and evaluate rules so delivery stays reviewable.
1. Which rules are worth using as-is?
Teams often want a set of rules they can paste into an AI coding assistant and immediately get better results. A common pattern is to force research, then design, then plan, then implement, then review—and to make every reply declare the current stage.
That workflow has value, but it is not the best starting point for every task. A simple parameter fix does not need a full multi-stage ritual. A refactor of permissions or data structures, without impact analysis, can be dangerous if the assistant jumps straight to edits.
Out-of-the-box rules should provide a clear foundation rather than the same heavy process for every job. That foundation usually covers four areas:
- Project facts: how dependencies are managed, how to run verification, and what each directory is for.
- Change boundaries: which files are protected and which operations need approval.
- Done criteria: which checks must run and how results should be reported.
- Uncertainty: when to ask questions versus when to proceed.
The goal is not to make the assistant repeatedly announce that it is following the rules. It is to reduce guessing, reduce wrong edits, and make results easy for developers to verify.
2. Separate project facts, behavioral constraints, and engineering controls
Before writing rules, split information by type.
2.1 Project facts: what the model cannot know from general programming knowledge
Examples:
- Which command or entry point installs dependencies.
- Which directory holds compatibility shims.
- Which shared layer must wrap external requests.
- Which files are generated by automation.
- Which environment variables local verification needs.
Keep these concrete and point to real docs or files. Prefer “business modules must not talk to storage directly; use the existing data-access layer” over “follow the project architecture.”
Do not paste an entire project guide into the rules. If a stable source of truth exists, say where to look and how to resolve conflicts.
2.2 Behavioral constraints: mistakes that can still happen after the facts are known
Use these to limit high-risk decisions. Examples:
- Do not change expected test results just to make tests pass.
- Do not delete public APIs without confirmation.
- Do not put real credentials in source or fixtures.
- Do not overwrite unrelated user edits.
State triggers and what to do. “Do not break compatibility” is too vague. “When changing a public API, list callers and say whether compatibility handling is required” is checkable.
2.3 Engineering controls: prompts cannot replace real safeguards
Rules are soft constraints. They do not replace permissions, automated checks, or human review. Even if a rule says “do not touch protected directories,” access control, change approval, or check scripts should still reduce accidents.
“Do not leak secrets” does not replace credential management and secret scanning. Rules can nudge correct behavior; real security boundaries must be built into the engineering system.
3. A minimal rule template you can adapt
The following is generic text, not a vendor-specific config format. Replace bracketed placeholders with project facts. Storage, loading, and matching syntax depend on your environment.
Project baseline rules1. Project information- Install dependencies, run tests, and run static checks via: [project entry points].- Architecture and directory roles follow: [authoritative docs].- If an entry point is unclear, inspect existing config first; do not invent an alternative.2. Scope of changes- Change only files required for the current request.- Do not overwrite existing user changes unrelated to the task.- Do not manually edit [compatibility directory] or [generated directory] without confirmation.- For dependency manifests and lockfiles, explain why they must change and follow the established update process.3. Verification- After changes, run task-relevant tests and the project’s required static checks.- Do not hide failures by deleting tests, skipping cases, or casually changing expectations.- If verification cannot run, state why; do not claim it passed.4. Requirements and risk- If a requirement is ambiguous in a way that affects behavior, ask specific questions first.- For data deletion, permission changes, or public API changes, explain impact and confirm first.5. Delivery notes- Summarize what changed, verification results, and remaining issues.- Distinguish verified facts, reasonable inferences, and items still unconfirmed.
The template deliberately omits slogans such as “code must be elegant” or “always use best practices.” Those goals matter, but they lack a clear acceptance boundary and become untestable.
Protecting lockfiles does not mean never changing them. Dependency upgrades may require coordinated updates. Good rules ban unrelated edits and hand-made inconsistency, not normal maintenance.
4. Keep global rules short; add scoped rules as needed
If every rule is injected into every task, the assistant processes extra noise. That costs context and can dilute the constraints that matter. Organize by scope.
4.1 Global rules: only requirements that usually apply
Put dependency entry points, change boundaries, verification floors, and risk-confirmation rules in the global set.
Do not dump per-file coding standards into global rules. UI state rules mixed with database-migration rules are hard to read and easy to misapply.
4.2 Scoped rules: conventions for a module
If the environment can load rules by path, attach constraints to UI components, service APIs, migrations, and tests. If not, cite the relevant rules at the start of a task.
UI example:
Scope: [UI component directory]- Prefer existing base components.- New interactions must cover loading, empty, failure, and success states.- Form errors must be visible to users, not only logged internally.- When interaction logic changes, add matching behavioral tests.
Migration example (different emphasis):
Scope: [data migration directory]- State preconditions, data impact, and how to recover from failure.- Do not assume production data can be wiped or rebuilt.- For destructive changes, propose backup and verification first.- Say whether recovery is migration rollback, forward fix, or restore from backup.
Do not require every migration to be fully reversible. Some transforms cannot be undone completely. Rules should require an honest statement of limits and a reliable recovery plan.
5. Process should match risk, not a fixed ceremony
Research, design, plan, implement, and review can organize work. They describe activities; they need not be labels on every reply.
5.1 Simple tasks: a short path
For well-bounded, low-impact edits: understand the problem → find the code → change it → verify → summarize.
The point is necessary checks, not a long plan. Fixing one condition is usually better served by reading the implementation and tests than by writing a full design first.
5.2 Medium tasks: a short plan of decisions
For changes across modules, state first:
- Which modules you expect to change.
- Which existing behaviors must stay.
- Which tests you will add or adjust.
- Whether any API ambiguity needs user confirmation.
Focus on decision points, not line-by-line predictions. Over-detailed plans go stale after exploration.
5.3 High-risk tasks: confirmation before execution
Permission changes, bulk data work, and external protocol changes need impact analysis before implementation. For irreversible or hard-to-recover work, confirmation must happen before execution, not as a disclaimer afterward.
A practical process rule: “Choose depth based on impact; for high-risk operations, explain the plan and get confirmation first.” That is more useful than one fixed stage list for every task.
6. Stop “tests went green, but the bug remains”
Passing tests are evidence, not proof of correctness. An assistant may treat the goal as “make failures disappear” by deleting failing cases, weakening assertions, or changing expected results.
Do not only write “never edit tests.” Tests can be outdated or wrong; a total ban blocks real work. Distinguish three cases:
- Implementation does not match the agreed requirement: fix the code, keep valid tests.
- The requirement clearly changed: update implementation and tests together, and cite the reason.
- Test expectations are wrong: explain why, with independent evidence.
When tests fail, delivery notes should record where they failed, a first-pass cause, whether the failure relates to this change, and what was done. Unexplained failures should not be treated as ignorable without confirmation.
Also distinguish “ran” from “passed.” If the environment lacks dependencies, permissions, or test data, report blocked verification; do not infer that everything would pass from reading the code.
7. Grow rules from real, costly, repeatable mistakes
A practical maintenance rule: add rules first for errors that already happened, were expensive, and may recur.
If the assistant bypassed the shared request layer, add: “Business code must not construct external requests directly; new calls must reuse the existing request entry.” If the root cause is unclear directory ownership, a new rule is not enough—improve docs or checks too.
Before adding a rule, ask:
- Is this a stable project requirement?
- Can a person or an automated check verify it?
- Is there already a stronger control?
- Will this rule block legitimate work?
Delete rules too. Review on a project cadence: stale entry points, retired directories, duplicates, and contradictions. Rules for a one-off migration should expire or be archived when the work ends.
Do not drop a rule only because it was not recently violated. Keep security and data-protection rules based on risk, not recent incident counts.
8. How to tell if rules actually work
Do not judge rules by whether the assistant mentions them. Watch outcomes:
- Fewer unrelated file edits.
- Less rework from ambiguous requirements.
- Honest, stable verification reports.
- Earlier visibility of high-risk operations.
- Less hiding of problems by weakening tests.
- Fewer times developers re-supply the same background.
You do not need a heavy metrics system. In code review, log typical violations and decide whether the cause was a missing rule, an unclear rule, missing context, or missing engineering controls.
If rules are ignored, shorten them, tighten scope, or turn the requirement into an automated check—do not keep stacking more emphasis.
Conclusion: good rules index project knowledge and define delivery bounds
Reusable AI coding rules are not a large manifesto of behavior. They are a small set of clear, verifiable project constraints.
Start with a minimal template for facts and done criteria, then add scoped rules by module. Keep ordinary tasks light; add confirmation points for high risk. Add rules from real failures, prune them as the project changes, and put critical safety requirements in engineering controls.
Well-written rules do not only make the assistant more obedient. They make it guess less, easier to review, and more likely to finish work inside the right boundaries.
