How to Make AI Coding Assistants Follow Exact Instructions Without Being "Smart"
Problem
When I asked an AI coding assistant to add the prefix _TEST_ to my environment variables, it kept giving me TEST_ instead.
I asked for this:
_TEST_DATABASE_URL=jdbc:postgresql://localhost:5433/db_TEST_DB_USERNAME=postgres_TEST_DB_PASSWORD=passwordBut the AI gave me this:
TEST_DATABASE_URL=jdbc:postgresql://localhost:5433/dbTEST_DB_USERNAME=postgresTEST_DB_PASSWORD=passwordThe AI removed the leading underscore because it thought it was a mistake.
What happened?
I was setting up test environment variables for a database connection. My team uses the convention _TEST_ (underscore before TEST) to mark test variables. This is intentional—the leading underscore has a specific meaning in our system.
Here’s what I asked the AI:
add these DATABASE_URL=jdbc:postgresql://localhost:5433/db, DB_USERNAME=postgres, DB_PASSWORD=password with _TEST_ prefixThe AI looked at this and thought:
- “Leading underscore before TEST? That’s unusual”
- “Standard convention is
TEST_prefix” - “I’ll fix this to be more helpful”
So it “corrected” my prefix from _TEST_ to TEST_.
This is a common problem. AI coding assistants (Claude, Copilot, Codex, ChatGPT) are trained to be helpful. They learn from billions of lines of code that standard conventions are usually “better.” When they see something unusual, they try to fix it.
But sometimes you don’t want help. You want exact, literal output.
How to solve it?
I tried several approaches. The first one that worked was using explicit negative constraints:
Transform these variables by adding the prefix "_TEST_".
IMPORTANT:- The prefix is "_TEST_" (underscore first, then TEST)- DO NOT remove the leading underscore- DO NOT apply standard conventions- Output EXACTLY as shown below
DATABASE_URL=jdbc:postgresql://localhost:5433/dbDB_USERNAME=postgresDB_PASSWORD=password
Expected output format:_TEST_DATABASE_URL=jdbc:postgresql://localhost:5433/db_TEST_DB_USERNAME=postgres_TEST_DB_PASSWORD=passwordThe key changes:
- Specified the exact prefix format: “TEST” (underscore first, then TEST)
- Added negative constraints: “DO NOT remove the leading underscore”
- Showed expected output format as example
This worked. The AI followed my exact instructions.
Another approach that works is quoting the exact output:
Output these lines EXACTLY, with zero changes:
_TEST_DATABASE_URL=jdbc:postgresql://localhost:5433/db_TEST_DB_USERNAME=postgres_TEST_DB_PASSWORD=password
Do not reformat. Do not interpret. Copy exactly.This tells the AI to treat the text as literal, not as something to interpret or improve.
A third approach is step-by-step instructions:
For each variable below:1. Take the variable name (e.g., "DATABASE_URL")2. Insert the string "_TEST_" at the beginning3. Keep the value unchanged4. Output as "variable=value"
Variables to transform:- DATABASE_URL=jdbc:postgresql://localhost:5433/db- DB_USERNAME=postgres- DB_PASSWORD=password
Example: If input is "FOO=bar", output is "_TEST_FOO=bar"This breaks down the transformation into unambiguous steps.
The reason
The AI “helpfully” changed my prefix because it’s trained to prioritize common patterns over literal instructions. It learned from code that:
TEST_is the standard prefix for test environment variables- Leading underscores before prefixes are unusual
- “Helpful” means correcting perceived mistakes
This is a feature—most of the time, you want the AI to catch and fix mistakes. But it becomes a bug when you need exact, literal output.
The solution is to be explicit about what NOT to change. Negative constraints (“DO NOT reformat”) work better than positive ones (“keep the same format”). Examples help the AI understand exactly what you want. When you show the expected output, the AI can match the pattern instead of guessing.
There are specific situations where exact output matters:
- Configuration files where syntax must be preserved
- Legacy systems with non-standard conventions
- Team-specific naming patterns
- Reproducible builds where “helpful” changes break consistency
- Testing where you need the exact broken state, not a fixed version
Summary
In this post, I showed how to make AI coding assistants follow your exact instructions without interpreting or improving them. The key point is using negative constraints, providing concrete examples, quoting exact output, and breaking down transformations into step-by-step instructions. When you need literal obedience instead of helpful interpretation, treat the AI as a code transformation tool, not an assistant.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments