Navigating Vibe Coding with GitHub Copilot — A Developer’s Guide to Taming AI Hallucinations and Boosting Productivity
Vibe coding — using AI like GitHub Copilot in VS Code to intuitively build apps via natural language “vibes” — is a game-changer for rapid prototyping. Think: spinning up a React SPA frontend, Fast API backend, Docker container, and Azure deployment in a flash. But as many developers know, it’s riddled with frustrations: inaccurate models, forgotten instructions, and code-killing overhauls.
In this guide, we’ll unpack the top issues I ran into over an exhaustive period of three weeks in which I deep-dived into Vibe coding to arm you with battle-tested mitigations that I found useful to overcome deficiencies and performance issues.
Whether you’re battling GPT-5’s laziness or Claude Sonnet 4’s logic loops, these strategies will help you vibe code faster, safer, and with fewer Git reverts. For this article and the my testing, I focused specifically on GPT-5 and Claude Sonnet 4 exclusively. My opinion on other models is best saved for another article, which I’m sure will be out shortly.
What Is Vibe Coding, Anyway?
At its core, vibe coding lets you describe high-level ideas (“Make a secure login vibe”) and lets AI generate code iteratively. It’s ideal for less complex and smaller applications, but even then, it has difficulty. The LLMs’ probabilistic nature breeds errors — misinterpretation, errors, hallucinations in at least 30% of suggestions. And this seems to be wide-spread consensus.
The payoff? A dramatic acceleration in prototyping — 2–3x faster iteration cycles that unlock creativity and momentum.
While the journey isn’t without its bumps — AI still has growing pains, and repo stability can be a challenge — the experience offers invaluable insights into the future of development. Each hiccup is a signal of progress in motion, revealing where human oversight and AI collaboration can evolve. We’re not quite at the finish line for fully autonomous software engineering, but the trajectory is promising. With every experiment, we’re shaping tools that will one day transform how meaningful software gets built.
Vibe Coding issues you may run into (and How to Fix Each.)
1. Hallucinations & “Incorrect” responses
Problem: AI says it updated files or fixed bugs but changed nothing — common in Ask-mode where it can’t actually write files. (Because it needs to be in Agent-mode.)
Fix:
- Always switch to Agent-mode tools (Cursor, Aider, Continue).
- Prompt: “Apply changes, then run
git statusand list modified files.” - Run
git diffafter every AI change. Automate this with a pre-commit hook. - You must manually verify the file changes it makes. You cannot rely on the models to tell you the truth. I found 8 times out of 10, the model produces incorrect code, no matter how good your prompts are.
2. Instruction Ignorance
Problem: Models ignore your rules or style guides.
Fix:
- Add a
.aiconfig.jsonor.\github\copilot-instructions.mdfile at the project root. Point models to it every session. - Prompt hack: “Follow every rule in
copilot-instructions.mdwithout exceptions.” - Use Claude for strict adherence, GPT for creativity, and rotate if one gets “lazy” or stuck in logic loops (or just can’t solve a problem in the first few iterations.)
3. Overkill Refactors
Problem: You ask it to fix one function, it rewrites your entire backend.
Fix:
- Use atomic prompts: “Only edit
orders.py→process_order()— no other files.” - Commit before AI changes (
git commit -am "checkpoint") so you cangit reset --hard HEAD~1if needed. - If stuck, force it to propose a minimal patch before applying it.
- Give it specific instructions to “only” modify the files necessary to complete the task and to not modify any other files.
4. Context Drift (New)
Problem: The AI loses context mid-session, causing incoherent logic.
Fix:
- Restart chats regularly — don’t carry 100+ messages of history.
- Provide fresh, minimal context (only relevant files) each session.
- Use tools like Aider or Cursor that manage context smartly.
5. Script Fails on Windows
Problem: These AI models are terrible at writing inline scripts on Windows 11. Either the model assumes Linux/Mac script syntax or doesn’t know Windows 11 syntax and produces incompatible inline scripts. It rarely gets inline scripting syntax correct and usually fails-out. But not before it tries repeatedly to execute the same logic with slight syntax differences, none of which ever execute correctly.
Fix:
- Prompt: “Target Windows 11. Test inline with
pwshbefore finalizing.” - Run in WSL2 to bypass Windows quirks entirely.
- Validate every script manually and correct the syntax yourself using a different model. You can then train the model you are using with the correct syntax.
- Ask the model to research the scripting language and version you are using and the proper syntax for execution on a Windows 11 system. (This sounds like it should solve the problem, but it doesn’t. It does help however.)
6. Sluggish Responses
Problem: Sessions slow down, history bloats.
Fix:
- Start fresh chats when latency spikes.
- Close unrelated tabs and files to reduce token noise.
- Swap models — if GPT stalls, try Claude or vice versa. Remember that each model has a different set of strengths based on the data it has been trained on. Using LLM Model Benchmarking test results to determine which model performs best depending on the task at hand.
- Think about cleaning up your repo. Delete all outdated files, documentation, temp files, temp scripts and anything else that may confuse the model. Re-add any necessary files once your application is stable.
7. Copilot or Plugin Crashes
Problem: Copilot/Aider extensions randomly crash.
Fix:
- Update extensions weekly, clear cache.
- Enable verbose logging to trace crash points.
- If stuck in a crash loop, disable all other VS Code plugins temporarily.
- Understand that if you have MCP Servers enabled, these too can cause massive problems with little optics into what the MCP Server is actually doing underneath the covers. You may want to disable MCP Servers that provide the same functionality you can perform yourself in the terminal. i.e. Instead of using an Azure MCP Server, just have the model use the Azure CLI locally.
- I have had to uninstall and re-install the GitHub CoPilot extension multiple times to clear bad states in can get into.
8. Memory Blackouts
Problem: It forgets previous decisions or conventions.
Fix:
- Keep a custom
ai-memory.mdfile (in addition to the copilot-instructions.md file) with architecture decisions, naming rules, component names and locations, etc. - Prompt: “Summarize
ai-memory.mdand follow all decisions before coding.” - Use Claude’s long-context mode if possible.
9. Junky or Unscalable Code
Problem: Fragile logic, fake mocks, poor structure.
Fix:
- Require real tests: “Write live unit tests with real data. No mocks, no fakes, no facades. All unit tests must pass. Do not allow any errors or warnings in the logic you create. Do not bypass unit tests. Do not fake results.”
- Enforce linters (
eslint,pylint) and run CI after each commit. - Cap attempts: “Stop after 5 iterations and request review.”
10. Security Gaps
Problem: Insecure code patterns or leaked secrets.
Fix:
- Run GitGuardian, Snyk, or Trivy scans on every PR.
- Prompt: “Apply OWASP Top 10. Sanitize all inputs.”
- Use local/offline mode when working with sensitive data.
11. Merge Conflicts & File Blind Spots
Problem: AI edits old file versions, creating silent conflicts.
Get Greg Unger’s stories in your inbox
Join Medium for free to get updates from this writer.
Fix:
git pulland rebase before every AI session.- Enable VS Code GitLens to catch drift early.
- Force AI to show
git diffbefore commit. - Check-in often (git) (especially whenever you have a stable codebase after changes have been made.) Chances are you will need to revert back to a stable checkpoint if the model pollutes the codebase to an unrecoverable point.
12. Env Glitches & Dependency Decay
Problem: Docker/Azure configs silently break, or old deps rot.
Fix:
- Use
docker compose build --no-cacheto ensure clean builds. - Add automated dependabot or renovate for dependency updates.
- Lock versions in
requirements.txt/package-lock.json.
13. Model Inconsistency
Problem: Different model variants output wildly different quality.
Fix:
- Do not be afraid to rotate between models (Claude for planning, GPT for codegen, Copilot for inline fixes). Re-initialize the model each and every time with your instructions and custom ai memory files, including any other requirements documentation before the model proceeds to make changes. You may have to do this multiple times during a single session.
- Document which model did what in PRs for accountability.
14. Skill Erosion
Problem: Relying on AI dulls your debugging chops.
Fix:
- Set “AI-free days” — solve bugs manually.
- Treat AI as a code generator, not a thinking substitute.
15. Prompt Debt
Problem: Prompt instructions pile up, confusing the model.
Fix:
- Refactor your prompts like code: keep them modular, short, and versioned.
- Maintain a
prompt-library.mdand link the one you want the AI to follow. - Use AI to create clear and concise prompts with as little ambiguity as possible. Use consistent syntax and prompt style conventions so the AI model has less of a chance of being confused.
The Safe & Performant Vibe Workflow
- Prep: Define goals in
copilot-instructions.md.git commita clean baseline. - Vibe: Use Agent-mode tools (Cursor, Aider) with precise, atomic prompts.
- Validate: Run
pytest,eslint,docker build, etc. after every AI edit. - Iterate: Max 3–5 cycles per feature. Then stop and regroup.
- Audit: Human code review. Merge only after sign-off.
- Clean-up files: Delete all unnecesarry files in your repository. Make sure all files are up to date and accurate after changes have been made to the codebase. Make sure your instruction or memory helper files stay current as well.
This disciplined loop turns chaotic AI output into production-ready code. Studies and user reports show 50–70% fewer issues using these guardrails.
Bypassing Approvals & Configuring Max Iterations in VS Code Copilot
One last thing to mention and it is a huge time-saver.
One way to streamline your vibe coding workflow is to let the AI (Copilot in Agent mode) run certain commands without needing you to click “Approve” every time, and to configure how many iteration cycles it will perform before asking for input. VS Code supports settings to enable this (experimentally)— though, as always, enable them with caution.
Here’s how to set them up, what settings to tweak, and best practices.
How to Auto-Approve Commands
VS Code’s Copilot Agent has built-in settings you can configure so that certain terminal commands and tool invocations are auto-approved, removing friction. These options let you allow specific trusted commands (or all commands) to run without manual confirmation.
How To Set Them in settings.json
You (or your team) can put something like this in your VS Code User or Workspace settings.json:
- Workspace settings override user settings when opening that workspace.
- If you set
global.autoApprove, that tends to override more specific terminal/command-based denies unless they are explicitly defined. Always test.
How to Configure in the VS Code UI
- Open Settings (Ctrl/Cmd + ,)
- Search for Copilot Agent or chat.tools.autoApprove
- Toggle
Auto-approve all tools - Under Terminal Commands Auto-Approve, you can add allowed/denied commands manually
Some of these are experimental or might require a newer version of VS Code / the Copilot extension. Also may be restricted in enterprise settings.
Limiting AI Iterations (Max Requests)
You also don’t always want the agent to run indefinitely (or for dozens of small fix-cycles) without oversight. There is a setting to cap how many chained requests the agent can make before stopping and asking you.
- Setting:
chat.agent.maxRequests - Default: Often 25 for many users in the standard Copilot Agent setup.
- What It Does: Controls how many internal “steps” or “tool+command executions + code edits + validations” the agent can do before it pauses and asks for your review.
- How to set in
settings.json:
{
"chat.agent.maxRequests": 10
}Lower values = more manual checkpoints. Higher values = more autonomy (but also risk).
Combining Both: A More “Autonomous but Safe” Workflow
Here’s one pattern you can recommend in your article:
- Enable Agent Mode but keep some guards on.
- Set auto-approve only for safe commands (e.g.
npm install,git status, maybe build/test commands), deny anything that can delete or change permissions. - Set
maxRequeststo something moderate, e.g. 5-10 per feature request. - Have a
dev-instructions.mdor config file that lists what commands are safe, naming conventions, etc. Tie the autoApprove settings to that policy. - Periodic review: If the workflow shows destructive behavior, dial the autoApprove settings back.
Best Practices & Warnings
- Security: Allowing autoApprove globally is risky. A hallucinated or malicious prompt from AI could execute harmful commands (even beyond your intention).
- Version control hygiene: Always have a clean checkpoint or commit before letting the agent run many steps.
- Auditing: Use
git diff, CI tests, linter runs after the fact. Maybe even automated scanning of terminals commands for dangerous patterns.
Conclusion: Master the Model, Harness the Flow
Vibe coding is powerful — but power without control is messy. The same AI that can generate full-stack apps in minutes can also derail projects with silent errors, hallucinated rewrites, and security holes if left unchecked.
The key is discipline. Treat AI as a junior developer: eager, fast, but needing boundaries, reviews, and guardrails. Anchor every session with explicit instructions, frequent commits, and automated tests. Use tooling like Copilot Agent, Aider, or Cursor to manage context, and configure VS Code to strike the right balance between autonomy (auto-approved commands, capped iterations) and safety (linting, CI, version control, and manual audits).
With this approach, vibe coding shifts from reckless experimentation to deliberate acceleration. You gain speed without sacrificing stability, creativity without losing control. Instead of fighting the chaos, you’ll harness it — turning AI from a liability into your most productive teammate.
About the Author:
For over three decades, Greg Unger has been at the vanguard of technological innovation, transforming complex challenges into strategic triumphs. As a hands-on expert in Artificial Intelligence, Quantum Technologies, Machine Learning, Cloud Architecture (AWS, Azure, GCP), Data Engineering, and Cybersecurity, he consistently deliver groundbreaking solutions for the most demanding environments. His career is defined by a relentless pursuit of excellence, leading elite teams to conquer the toughest problems in mission-critical systems across the military, government, financial, and biotechnology sectors. He is a proven leader, adept at fostering high-performing teams and delivering multi-million dollar projects on time and within budget, consistently exceeding expectations and driving unparalleled customer success. His direct, positive, and self-driven approach, coupled with an unwavering attention to detail, ensures he not only meets but anticipates the evolving needs of the most advanced technological landscapes.
You can find me here: #UngerWasHere








