{"slug": "ai-coding-workflow", "title": "AI coding workflow", "summary": "A developer reports that their Cursor config file reached 847 lines, calling it a problem rather than a flex, and details a workflow that ships code with AI, including committing a CLAUDE.md or CURSOR.md to every repo, which cut correction cycles by 3.2x on a 2,400-line refactor. The workflow includes using Cmd+K for inline edits, a custom keybinding for new files from selection (used 47 times in a sprint), test-driven AI with failing tests first, routing tasks to models like GPT-4o-mini for boilerplate (saving ~$180 last month), and a pre-commit hook for reviewing diffs.", "body_md": "# AI coding workflow\n\n[Cursor](/en/tags/cursor/)config file hit 847 lines last week. That's not a flex — it's a problem.\n\n## The workflow that actually ships code\n\nMost developers treat AI like a magic wand. Type prompt, get code, copy-paste, pray. That's not a workflow. That's gambling with better UX.\n\nReal workflow means the AI knows your codebase, your conventions, your test suite, and your deployment pipeline. It means the feedback loop stays under 30 seconds end-to-end.\n\nHere's what that looks like in practice.\n\n### Rule zero: context is everything\n\nCursor's `@codebase`\n\nindexing catches maybe 60% of what you need. The other 40% lives in your head — or in that `ARCHITECTURE.md`\n\nfile nobody updates.\n\nI started committing a `CLAUDE.md`\n\n(or `CURSOR.md`\n\n) to every repo:\n\n```\n# Project Context for AI\n\n## Stack\n- Next.js 14.2 (App Router), TypeScript strict\n- Tailwind + shadcn/ui, no custom CSS\n- TanStack Query v5 for server state\n- Prisma + PostgreSQL, migrations in `/prisma`\n\n## Conventions\n- Server components by default, `'use client'` only when forced\n- API routes under `/app/api`, never `/pages/api`\n- Zod schemas co-located with actions in `/lib/validations`\n- Error boundaries per route segment, not global\n\n## Testing\n- Vitest + React Testing Library\n- Run `pnpm test:watch` during development\n- E2E with Playwright in `/e2e`, CI runs on push\n\n## Forbidden patterns\n- No `any` types — use `unknown` + narrowing\n- No direct DB calls in components\n- No `console.log` in committed code (use `logger.debug`)\n```\n\nBefore: 12 back-and-forth messages explaining the stack every session. After: the model just works. Measured 3.2x fewer correction cycles on a 2,400-line refactor last Tuesday.\n\n### The shortcut that saves hours\n\n`Cmd+K`\n\n(inline edit) with a selection is faster than chat for 80% of tasks. But the real unlock is binding a custom key to \"apply to new file from selection.\"\n\n```\n// keybindings.json\n{\n  \"key\": \"cmd+shift+n\",\n  \"command\": \"cursor.newFileFromSelection\",\n  \"when\": \"editorTextFocus && editorHasSelection\"\n}\n```\n\nHighlight a component, hit the chord, get a new file with imports wired, types inferred, and the export statement ready. Used this 47 times last sprint. Not exaggerating.\n\n### Test-driven AI — not optional\n\nHere's the bug that taught me: asked Cursor to add pagination to a table. It generated the UI, the API params, the Prisma query. Looked perfect. Shipped to staging.\n\nProduction blew up because the `cursor`\n\nparameter collided with a reserved Prisma keyword. The fix took 4 minutes. Writing the failing test first would've taken 30 seconds.\n\nNow every AI task starts with:\n\n```\n# Terminal 1: watch mode\npnpm test:watch -- --testNamePattern=\"pagination\"\n\n# Terminal 2: Cursor chat\n\"Add cursor-based pagination to the user table. \n Tests in __tests__/user-table.pagination.test.tsx \n should pass. Follow existing patterns in __tests__/helpers.\"\n```\n\nThe model writes code *to make tests green*. Different mindset entirely.\n\n### Model routing: stop using one hammer\n\n| Task | Model | Why |\n\n|------|-------|-----|\n\n| Boilerplate, types, tests | GPT-4o-mini | 0.8¢/1k tokens, 95% accuracy on rote work |\n\n| Architecture decisions | [Claude](/en/tags/claude/) 3.5 Sonnet | Handles ambiguity, explains tradeoffs |\n\n| Debugging obscure errors | o1-preview | Reasoning traces catch what others miss |\n\n| Quick refactors | Cursor-small (local) | Sub-200ms latency, no context window tax |\n\nI routed 73% of last month's AI calls to the cheap model. Saved ~$180. The [AI Models](/en/category/ai-models/) breakdown shows exactly where each shines — and where they hallucinate.\n\n### The \"review before apply\" muscle\n\nCursor's diff view is decent. GitHub's is better. I configured a pre-commit hook that forces me to see the unified diff in the terminal before anything lands:\n\n``` bash\n# .husky/pre-commit\n#!/bin/sh\ngit diff --cached --no-color | head -200\necho \"---\"\necho \"Review above. Commit? [y/N]\"\nread -r confirm\n[ \"$confirm\" = \"y\" ] || exit 1\n```\n\nAnnoying? Yes. Caught 3 production bugs last quarter that tests missed? Also yes.\n\n[MCP](/en/tags/mcp/) servers: the force multiplier nobody talks about\n\nModel Context Protocol lets the AI *do* things — query your DB, hit your API, spin up a preview deployment. Not just *suggest* things.\n\nMy `.cursor/mcp.json`\n\n:\n\n```\n{\n  \"mcpServers\": {\n    \"prisma\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@prisma/mcp-server\"],\n      \"env\": { \"DATABASE_URL\": \"postgresql://...\" }\n    },\n    \"github\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-github\"],\n      \"env\": { \"GITHUB_TOKEN\": \"${GITHUB_TOKEN}\" }\n    },\n    \"vercel\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@vercel/mcp-server\"],\n      \"env\": { \"VERCEL_TOKEN\": \"${VERCEL_TOKEN}\" }\n    }\n  }\n}\n```\n\nNow I can say \"check if the migration I just wrote breaks production data\" and it *runs the query against staging*. \"Open a PR with the fix\" — done. \"Deploy preview\" — URL in chat.\n\nThis is where the [Workflows](/en/category/workflows/) category pays off — real examples from people shipping this way.\n\n### One concrete bug + fix\n\n**Symptom**: Cursor's `@codebase`\n\nstopped indexing after a `pnpm install`\n\nthat upgraded TypeScript 5.4 → 5.5.\n\n**Root cause**: `.cursor/indexingignore`\n\nhad `node_modules/**`\n\nbut the new TS version ships declaration maps in `node_modules/typescript/lib/*.d.ts.map`\n\n— which the indexer tries to parse and chokes on.\n\n**Fix**: Added `**/*.d.ts.map`\n\nto `.cursor/indexingignore`\n\n. Re-indexed. 47 seconds.\n\n```\n# One-liner to add it\necho \"**/*.d.ts.map\" >> .cursor/indexingignore && cursor --reindex\n```\n\nTook me 3 hours to trace. You're welcome.\n\n### The part where I admit I'm wrong\n\nI used to think \"agent mode\" (Cursor's Composer, [Claude Code](/en/tags/claude%20code/)'s `--dangerously-skip-permissions`\n\n) was a gimmick. Let the AI run commands? Madness.\n\nThen I watched a colleague refactor a 14-file API migration in 6 minutes. The agent: read the OpenAPI spec, generated Zod schemas, updated controllers, rewrote tests, ran the suite, fixed two failing assertions, committed.\n\nI still don't trust it on `main`\n\n. But on a feature branch with CI gates? It's a different tier of velocity.\n\n### What's not working yet\n\n- Multi-file refactors across 20+ files still drift. The model loses the thread.\n- TypeScript inference breaks on complex generics — manual intervention required.\n- No good way to \"teach\" the model a new pattern permanently.\n`CLAUDE.md`\n\nhelps but it's context-window expensive. - Local models (Llama 3.1 70B, Qwen 2.5 Coder) still choke on framework-specific logic. Tried. Failed. Back to API.\n\n### The stack I'd bet on today\n\nCursor + Claude 3.5 Sonnet for reasoning. GPT-4o-mini for volume. MCP servers for actions. Vitest watch mode as the truth anchor. Git hooks as the safety net.\n\nNot perfect. But the first setup where the AI feels like a senior engineer who types 200wpm — not a junior who needs constant supervision.\n\nShip something with it this week. The config file grows. The velocity compounds.\n\n[Next Claude writes better Spring Boot configs than your senior dev →](/en/threads/6950/)\n\n## All Replies （0）\n\nNo replies yet — be the first!", "url": "https://wpnews.pro/news/ai-coding-workflow", "canonical_source": "https://promptcube3.com/en/threads/6975/", "published_at": "2026-08-19 21:38:11+00:00", "updated_at": "2026-08-19 21:44:12.914535+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "artificial-intelligence", "large-language-models"], "entities": ["Cursor", "GPT-4o-mini", "Claude 3.5 Sonnet", "o1-preview", "Cursor-small", "Next.js", "Prisma", "Playwright"], "alternates": {"html": "https://wpnews.pro/news/ai-coding-workflow", "markdown": "https://wpnews.pro/news/ai-coding-workflow.md", "text": "https://wpnews.pro/news/ai-coding-workflow.txt", "jsonld": "https://wpnews.pro/news/ai-coding-workflow.jsonld"}}