8. Using Cursor Without Trusting It Blindly
What this lesson actually teaches
Section titled “What this lesson actually teaches”Not “how to use Cursor” — how to constrain it. Two rule files (.cursor/rules/*.mdc) act as a standing style guide the agent reads automatically whenever it touches matching files: one pins integration tests to Node’s built-in node:test runner against real Postgres and Redis rather than mocks, the other pins k6 performance scripts to safe defaults — mandatory thresholds, parameterized load instead of hardcoded VU counts, and an explicit “never run full load against production” line. Both close off the two failure modes an unconstrained agent tends toward: defaulting to whatever’s most common in its training data (Jest, in this case, instead of the runner the project actually uses) and generating load-test scripts that run but never actually assert anything.
The habit that mattered more than the tool
Section titled “The habit that mattered more than the tool”Cursor’s agent reported success on the first integration test — wrote the diff, ran the test itself, and said it passed. The transcript never showed raw stdout, no visible exit code, just the agent’s summary. Running npm run test:integration independently afterward, watching for pass 1 / fail 0 and checking echo $? for a real 0, wasn’t redundant — it was the actual point. An agent’s self-report is a claim, not a result.
That discipline caught something concrete later in the same session: after a VM environment issue, both rule files turned out to be missing entirely — created once, never actually committed, silently gone. Re-created and committed immediately this time, with a git status check built into the workflow going forward specifically because the same thing had already happened once.
A real bug that needed two separate fixes, not one
Section titled “A real bug that needed two separate fixes, not one”The first k6 run against the API failed 100% of requests. The instinct is to blame Docker networking — a container’s localhost refers to itself, not the host — but checking whether the backend was even reachable from the VM directly (curl http://localhost:3001/health, connection refused) showed the real problem: nothing was listening at all. Starting the backend and re-running still failed, until --network host was added to let the k6 container actually reach a process running on the host. Both fixes were required together — the backend being down and the missing network flag were two independent problems that happened to produce the identical symptom, and fixing only one would have looked like it worked while still failing for the other reason.
Why the constraints matter more than the scaffolding
Section titled “Why the constraints matter more than the scaffolding”The riskiest part of the whole exercise wasn’t the tests themselves — it was the one refactor Cursor needed to make to enable them: exporting Express’s app object instead of calling .listen() immediately, guarded so production startup doesn’t break. The rule file specifies exactly how to do that safely and explicitly tells the agent to ask before anything bigger. That’s the actual value of writing rules down instead of re-explaining constraints in every prompt: the agent gets the same guardrails every time, and the person reviewing the diff knows exactly what changed and why.
How this looks in production
Section titled “How this looks in production”Mature teams treat AI-generated tests and YAML like a junior contributor’s first PR — fast to produce, mandatory to review, never merged on the strength of a chat transcript alone. A test suite that passes against mocks while the real database schema has drifted is a specific, common failure mode this lesson’s rules exist to prevent. The other one is secret sprawl — pasting .env values into a chat window is exactly the kind of thing that’s easy to do once under time pressure and expensive to walk back.
Next: Lesson 9, Local Observability.