AI coding workflow
The workflow that actually ships code
Most 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.
Real 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.
Here's what that looks like in practice.
Rule zero: context is everything
Cursor's @codebase indexing catches maybe 60% of what you need. The other 40% lives in your head — or in that ARCHITECTURE.md file nobody updates.
I started committing a CLAUDE.md (or CURSOR.md) to every repo:
# Project Context for AI
## Stack
- Next.js 14.2 (App Router), TypeScript strict
- Tailwind + shadcn/ui, no custom CSS
- TanStack Query v5 for server state
- Prisma + PostgreSQL, migrations in `/prisma`
## Conventions
- Server components by default, `'use client'` only when forced
- API routes under `/app/api`, never `/pages/api`
- Zod schemas co-located with actions in `/lib/validations`
- Error boundaries per route segment, not global
## Testing
- Vitest + React Testing Library
- Run `pnpm test:watch` during development
- E2E with Playwright in `/e2e`, CI runs on push
## Forbidden patterns
- No `any` types — use `unknown` + narrowing
- No direct DB calls in components
- No `console.log` in committed code (use `logger.debug`)Before: 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.
The shortcut that saves hours
Cmd+K (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."
// keybindings.json
{
"key": "cmd+shift+n",
"command": "cursor.newFileFromSelection",
"when": "editorTextFocus && editorHasSelection"
}Highlight 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.
Test-driven AI — not optional
Here'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.
Production blew up because the cursor parameter collided with a reserved Prisma keyword. The fix took 4 minutes. Writing the failing test first would've taken 30 seconds.
Now every AI task starts with:
# Terminal 1: watch mode
pnpm test:watch -- --testNamePattern="pagination"
# Terminal 2: Cursor chat
"Add cursor-based pagination to the user table.
Tests in __tests__/user-table.pagination.test.tsx
should pass. Follow existing patterns in __tests__/helpers."The model writes code to make tests green. Different mindset entirely.
Model routing: stop using one hammer

| Task | Model | Why |
|------|-------|-----|
| Boilerplate, types, tests | GPT-4o-mini | 0.8¢/1k tokens, 95% accuracy on rote work |
| Architecture decisions | Claude 3.5 Sonnet | Handles ambiguity, explains tradeoffs |
| Debugging obscure errors | o1-preview | Reasoning traces catch what others miss |
| Quick refactors | Cursor-small (local) | Sub-200ms latency, no context window tax |
I routed 73% of last month's AI calls to the cheap model. Saved ~$180. The AI Models breakdown shows exactly where each shines — and where they hallucinate.
The "review before apply" muscle
Cursor'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:
# .husky/pre-commit
#!/bin/sh
git diff --cached --no-color | head -200
echo "---"
echo "Review above. Commit? [y/N]"
read -r confirm
[ "$confirm" = "y" ] || exit 1Annoying? Yes. Caught 3 production bugs last quarter that tests missed? Also yes.
MCP servers: the force multiplier nobody talks about
Model Context Protocol lets the AI do things — query your DB, hit your API, spin up a preview deployment. Not just suggest things.
My .cursor/mcp.json:
{
"mcpServers": {
"prisma": {
"command": "npx",
"args": ["-y", "@prisma/mcp-server"],
"env": { "DATABASE_URL": "postgresql://..." }
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
},
"vercel": {
"command": "npx",
"args": ["-y", "@vercel/mcp-server"],
"env": { "VERCEL_TOKEN": "${VERCEL_TOKEN}" }
}
}
}Now 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.
This is where the Workflows category pays off — real examples from people shipping this way.
One concrete bug + fix
Symptom: Cursor's @codebase stopped indexing after a pnpm install that upgraded TypeScript 5.4 → 5.5.
Root cause: .cursor/indexingignore had node_modules/** but the new TS version ships declaration maps in node_modules/typescript/lib/*.d.ts.map — which the indexer tries to parse and chokes on.
Fix: Added **/*.d.ts.map to .cursor/indexingignore. Re-indexed. 47 seconds.
# One-liner to add it
echo "**/*.d.ts.map" >> .cursor/indexingignore && cursor --reindexTook me 3 hours to trace. You're welcome.
The part where I admit I'm wrong
I used to think "agent mode" (Cursor's Composer, Claude Code's --dangerously-skip-permissions) was a gimmick. Let the AI run commands? Madness.
Then 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.
I still don't trust it on main. But on a feature branch with CI gates? It's a different tier of velocity.
What's not working yet
- Multi-file refactors across 20+ files still drift. The model loses the thread.
- TypeScript inference breaks on complex generics — manual intervention required.
- No good way to "teach" the model a new pattern permanently.
CLAUDE.mdhelps 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.
The stack I'd bet on today
Cursor + 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.
Not perfect. But the first setup where the AI feels like a senior engineer who types 200wpm — not a junior who needs constant supervision.
Ship something with it this week. The config file grows. The velocity compounds.
All Replies (0)
No replies yet — be the first!
