{"slug": "stop-trusting-llms-to-handle-your-state-management-and-complex", "title": "Stop trusting LLMs to handle your state management and complex", "summary": "A developer account warns that LLM coding assistants such as Claude 3.5 Sonnet and Cursor predict likely tokens rather than execute logic, citing a TypeScript migration where AI-generated API wrappers passed the build but crashed at runtime because the invented interface did not exist in the actual library version v4.2. The account recommends forcing the model to read the real .d.ts file or documentation, locking global constraints in a .cursorrules or windsurf config, demanding diffs, and adopting a strict \"no new dependencies\" rule after an AI silently imported lucide-react into a heroicons project. It advises against using AI for architectural decisions spanning 20+ files, SQL versus NoSQL choices, complex CSS centering, and security audits of auth flows.", "body_md": "# Stop trusting LLMs to handle your state management and complex\n\n## Why is your AI code breaking in production?\n\nMost AI coding pitfalls happen because the model is predicting the most likely token, not actually executing the logic. It’s a pattern matcher, not a compiler.\n\nOne specific disaster I hit last month involved a TypeScript migration. I asked [Claude](https://promptcube3.com/en/tags/claude/) 3.5 Sonnet to refactor a set of API wrappers. It looked perfect. It used a pattern that looked exactly like a popular library's syntax. I merged it. The build passed because the types were technically valid (the AI had \"invented\" an interface that matched), but the runtime crashed because the actual library version I was using (v4.2) didn't have that method.\n\nThe fix isn't \"better prompting.\" It's changing how you verify.\n\n| Pitfall | The \"AI Smell\" | The Fix |\n\n| :--- | :--- | :--- |\n\n| Hallucinated APIs | Code looks clean but `npm start` fails with `undefined is not a function` | Force the AI to read the actual `.d.ts` file or documentation first |\n\n| Context Drift | AI forgets a constraint from 10 messages ago and reverts a bug fix | Use a `.cursorrules` or `windsurf` config file to lock in global constraints |\n\n| Over-Engineering | AI adds 5 design patterns for a simple fetch call | Explicitly prompt for \"KISS\" or \"no new abstractions\" |\n\n| The \"Just Trust Me\" loop | AI says \"I've fixed it\" but the code is identical to the broken version | Demand a diff or a specific explanation of what changed |\n\n## How to stop the \"Refactor Loop\" from eating your time\n\nWe've all been there: you ask for a change, the AI breaks something else, you ask it to fix that, and suddenly you're back to the original bug but with 200 lines of bloated code.\n\nThe mistake is treating the chat as the primary source of truth. Instead, use the \"Context Pinning\" strategy. If you're using [Cursor](https://promptcube3.com/en/tags/cursor/), don't just @-mention the file. Open the specific documentation page in the browser and use the `@Web` or `@Docs` feature to point the model to the *actual* current version of the library.\n\nTo be fair, some of these tools are getting better at this. But the \"lazy coding\" pitfall is still real. I once saw an AI replace a complex loop with a `// ... existing logic here ...` comment. If you blindly accept that, you've just deleted your codebase.\n\nCheck your diffs. Every single one. If you see `// ...` or `// rest of code stays the same`, reject the change. Force it to rewrite the whole block or use a tool that handles partial edits more surgically.\n\n## Fixing the \"Ghost Dependency\" bug\n\nLast Tuesday, I spent two hours debugging a `module not found` error because an AI decided to import `lucide-react` when I was using `heroicons`. It didn't tell me it was changing the library; it just wrote the code.\n\nTo prevent this, I started using a strict \"no new dependencies\" rule in my project instructions.\n\nTry adding this to your project rules:`\"Do not introduce new npm packages without asking first. If you need a utility, check if it already exists in @/lib or @/utils before suggesting a library.\"`\n\nThis one line saved me from adding three redundant utility libraries in a single sprint. It's a small config change, but it stops the \"dependency bloat\" pitfall dead in its tracks.\n\n## When to stop using AI for the task\n\nAI is terrible at high-level architectural decisions across 20+ files. If you ask it to \"restructure the folder system for better scalability,\" it will give you a generic folder structure that looks like a tutorial from 2022.\n\nThe wild part is that it will sound incredibly confident about it.\n\nStop using AI for:\n\n- Deciding between SQL vs NoSQL for a new project (it doesn't know your traffic patterns).\n- Complex CSS centering logic (it still hallucinates Flexbox vs Grid behavior in edge cases).\n- Security audits of auth flows (it often misses subtle race conditions).\n\nInstead, use it to generate the boilerplate for the decisions you've already made.\n\n## Leverage the community for better prompts\n\nYou don't have to figure out these patterns alone. I've found that the fastest way to avoid common AI coding pitfalls is to see how other developers are structuring their `.cursorrules` or their [MCP](https://promptcube3.com/en/tags/mcp/) (Model Context Protocol) servers.\n\nJoining a community like PromptCube is where this actually happens. It's not about \"prompt templates\" (which are usually useless), but about sharing actual project configurations. When you see a senior dev share a config that prevents the AI from using `any` in TypeScript or forces it to write Vitest tests for every new function, you save weeks of trial and error. You can dive into the [Resources](https://promptcube3.com/en/category/resources/) section to see how others are automating their workflows.\n\nThe real gain isn't the tool; it's the shared knowledge of where the tool fails.\n\n## The \"One-Shot\" verification workflow\n\nIf you're stuck in a loop, try this specific sequence. It usually breaks the cycle:\n\n1. **Clear the chat.** Context window pollution is why the AI starts repeating mistakes.\n\n2. **Feed it the error log.** Paste the exact terminal output.\n\n3. **Command it to \"Think Step-by-Step\" in a hidden block.** Tell it to analyze the call stack before writing a single line of code.\n\n4. **Restrict the output.** Tell it: \"Give me only the corrected function. Do not explain the change. Do not provide the rest of the file.\"\n\nThis forces the model to focus on the logic rather than the \"conversational\" filler that often masks the fact that it doesn't actually know the answer.\n\nDepending on the model version, this can reduce the \"hallucination rate\" significantly. On Claude 3.5, I noticed a marked difference in accuracy when I banned the \"Here is the updated code\" preamble.\n\n[Next Can Databricks Genie and Amazon Quick actually automate retail replenishment? →](https://promptcube3.com/en/threads/9374/)", "url": "https://wpnews.pro/news/stop-trusting-llms-to-handle-your-state-management-and-complex", "canonical_source": "https://promptcube3.com/en/posts/9384/", "published_at": "2026-09-14 23:15:42+00:00", "updated_at": "2026-09-14 23:25:43.451994+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-products"], "entities": ["Claude 3.5 Sonnet", "Cursor", "TypeScript", "lucide-react", "heroicons", "windsurf"], "alternates": {"html": "https://wpnews.pro/news/stop-trusting-llms-to-handle-your-state-management-and-complex", "markdown": "https://wpnews.pro/news/stop-trusting-llms-to-handle-your-state-management-and-complex.md", "text": "https://wpnews.pro/news/stop-trusting-llms-to-handle-your-state-management-and-complex.txt", "jsonld": "https://wpnews.pro/news/stop-trusting-llms-to-handle-your-state-management-and-complex.jsonld"}}