{"slug": "what-if-ai-coding-agents-could-predict-a-bad-code-change-before-making-it", "title": "What If AI Coding Agents Could Predict a Bad Code Change Before Making It?", "summary": "A developer built Preflight, an open-source tool that lets AI coding agents simulate refactoring plans on a graph representation of a codebase before editing source files. Using FalkorDB's GRAPH.COPY to create isolated graphs per plan, Preflight predicts impact, flags risky paths and ranks options; in an analysis of the invoke project it found a parameter change broke 59 call sites, one of which tests would miss because it was mocked. Tested against five real changes in cookiecutter, the tool currently supports Python function renames and parameter changes and has known static-analysis limits.", "body_md": "AI coding agents usually follow this loop:\n\nMake a change → Run tests → Fix errors → Try again.\n\nBut what if the first change was a bad idea from the start?\n\nThe agent may spend minutes or hours editing files and fixing errors, only to discover that another approach would have been much safer.\n\n**I wanted to help AI agents predict the impact of a code change before they start editing.**\n\nThat is why I built **Preflight**.\n\nGitHub: [https://github.com/VigneshPA-30/preflight](https://github.com/VigneshPA-30/preflight)\n\nImagine an AI agent wants to rename a function used across 50 files.\n\nInstead of making the change immediately, what if it could first ask:\n\nPreflight builds a graph of the codebase and simulates different refactoring plans on separate copies of that graph.\n\nIt predicts the impact of each plan, identifies risky paths and ranks the options.\n\nThe agent can then reject a bad approach **before touching the actual source code**.\n\nThe codebase is represented as a graph of functions, calls, imports, mocks and test relationships.\n\nFalkorDB makes it possible to follow these connections across multiple levels. Its `GRAPH.COPY` feature lets Preflight create an isolated graph for each proposed change.\n\nEach plan can be simulated separately without modifying the real graph.\n\nThis is not just about finding where a function is used. It is about understanding what could happen if we change it.\n\nOne interesting case came from my analysis of the open-source project `invoke`.\n\nChanging a function's parameters broke 59 call sites.\n\nTests were expected to catch 58 of them. One could remain hidden because its test mocked the function.\n\nPreflight identifies this as a masked breakage, helping the agent avoid trusting a path that looks safe but is not.\n\nI tested Preflight against five real changes in the open-source project `cookiecutter`, comparing its predictions with the actual test failures.\n\nThe results:\n\nThese are early results from one project, not a guarantee for every codebase. Preflight currently supports Python function renames and parameter changes, and static analysis has known limits.\n\nI believe the next step for AI coding agents is not just writing code faster.\n\nIt is **knowing which path is worth trying before spending time on it**.\n\nPreflight is my attempt to make that possible: predict the impact, compare the options, abandon risky paths early, and only then make the change.\n\n**Simulate first. Choose wisely. Then edit.**", "url": "https://wpnews.pro/news/what-if-ai-coding-agents-could-predict-a-bad-code-change-before-making-it", "canonical_source": "https://dev.to/vigneshpa_/what-if-ai-coding-agents-could-predict-a-bad-code-change-before-making-it-13ae", "published_at": "2026-10-18 10:39:32+00:00", "updated_at": "2026-10-18 10:44:54.831217+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "artificial-intelligence"], "entities": ["Preflight", "FalkorDB", "VigneshPA-30", "invoke", "cookiecutter"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/what-if-ai-coding-agents-could-predict-a-bad-code-change-before-making-it", "markdown": "https://wpnews.pro/news/what-if-ai-coding-agents-could-predict-a-bad-code-change-before-making-it.md", "text": "https://wpnews.pro/news/what-if-ai-coding-agents-could-predict-a-bad-code-change-before-making-it.txt", "jsonld": "https://wpnews.pro/news/what-if-ai-coding-agents-could-predict-a-bad-code-change-before-making-it.jsonld"}}