How to Prevent AI from Interpreting Your Instructions: Literal Prompt Engineering
Problem
When I ask AI coding assistants to create code with specific naming patterns, they keep “correcting” my requests to match standard conventions.
For example, I asked for:
Create a function myFunction_Name that adds two numbersBut got:
def my_function_name(a, b): # "Corrected" to snake_case return a + bThe AI saw my unusual underscore placement as a mistake to fix. I wanted myFunction_Name, not my_function_name.
This happens when AI tools prioritize “best practices” over what you actually asked for.
Environment
- AI coding assistants: Copilot, Codex, ChatGPT
- Use case: Non-standard naming requirements
- Context: Migration projects, legacy systems, testing scenarios
What happened?
I was working with a legacy system that uses non-standard variable naming. The existing codebase uses patterns like myFunction_Name instead of conventional my_function_name or myFunctionName.
I asked an AI assistant to generate new functions following this existing pattern. But the AI kept “helpfully” converting my unusual names to standard Python snake_case.
Here’s what I tried:
Attempt 1 - Simple request:
Create function myFunction_NameResult: def my_function_name(): (wrong)
Attempt 2 - Being more specific:
Create function named myFunction_Name with the exact same nameResult: def my_function_name(): (still wrong)
Attempt 3 - Emphasis:
Create function myFunction_Name - use this exact nameResult: def my_function_name(): (still being “helpful”)
The AI interpreted my unusual naming as a mistake I wanted corrected. I can explain why this happens:
- Training data reinforces “correcting” non-standard patterns
- AI models prioritize common conventions over user intent
- Lack of negative constraints leaves room for interpretation
How to solve it?
The solution is to explicitly tell the AI what NOT to do, provide examples, and use literal compliance phrases.
Solution 1: Negative Constraints
Tell the AI explicitly what to avoid:
Create a function myFunction_Name that adds two numbers.Do not change the naming style. Do not reformat to snake_case.Use the exact name specified.Now the output is correct:
def myFunction_Name(a, b): # Preserved as requested return a + bSolution 2: Explicit Examples
Show the exact input and output you expect:
Create a function named myFunction_Name.
Naming convention to follow:myFunction_Name (correct)my_function_name (incorrect)
Do not convert to standard conventions.Result:
def myFunction_Name(a, b): return a + bSolution 3: Literal Compliance Phrase
Start prompts with explicit instructions:
Follow instructions exactly as written. Do not interpret, correct, or optimize.
Create: myFunction_Name(a, b) returns a + bPreserve the exact underscore placement.Result:
def myFunction_Name(a, b): return a + bI found that combining these approaches works best:
Follow instructions exactly as written. Do not make assumptions or corrections.
Create function myFunction_Name.Constraints:- Do NOT use snake_case- Do NOT use camelCase- Do NOT "fix" the naming- Keep underscores exactly as shownIf the naming seems unconventional, you can add an escape hatch:
If the naming seems unconventional, do NOT correct it.Assume unconventional naming is intentional.For maximum control, use verbatim mode:
Output code verbatim. Do not apply linting, formatting, or style corrections.Treat all naming as intentional requirements.The reason
I think the key reason for this behavior is that AI models are trained on codebases where “correcting” unusual patterns is the right answer. They learn to optimize for best practices, not literal compliance.
When you ask for something non-standard without explicit constraints, the AI assumes:
- You made a mistake
- You want it corrected
- Standard conventions apply
Negative constraints override these assumptions by stating clearly:
- This is intentional
- Do not change it
- Follow exactly as written
Common mistakes
I’ve seen these patterns fail:
- Vague language: “Keep it similar” instead of “Keep it identical”
- No examples: Assuming AI will understand unusual patterns
- Missing negative constraints: Forgetting to forbid “helpful” corrections
- No escape hatch: Not addressing what to do with unconventional patterns
When this matters
This technique is useful for:
- Migration projects where non-standard naming must be preserved
- Integration with legacy systems using unconventional conventions
- Testing scenarios that require specific patterns
- Educational examples demonstrating non-standard approaches
Summary
In this post, I showed how to prevent AI coding assistants from interpreting or “correcting” your instructions. The key point is to combine negative constraints, explicit examples, and literal compliance phrases to override the AI’s “helpful” instincts.
The three core techniques are:
- Add explicit negative constraints (“Do not reformat, do not optimize”)
- Provide before/after examples showing exact output format
- Use literal compliance phrases (“Follow instructions exactly as written”)
This approach ensures AI tools follow your requirements literally instead of applying standard conventions when you need non-standard output.
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