Bad code. absurdly long scopes

I consistently see models generating insanely long functions with crazy amounts of scope nesting. I’m not sure what can be done about it but 1500 lines of code between an open brace and it’s corresponding closing brace is bonkers. The fact that models have a really hard time balancing braces is compounded by this complexity. It seems like a hard and fast rule to limit this would benefit every program in every language.

Hey, thanks for the feedback. The issue with generating overly long functions really does hurt readability and can make bracket balancing errors worse.

Try creating Project Rules to control code structure. In .cursor/rules, create a rule that clearly states your code quality requirements:

---
alwaysApply: true
---

-  Keep functions under 50 lines when possible
-  Limit nesting depth to 3 levels maximum
-  Break down complex logic into smaller helper functions
-  Extract repeated logic into reusable functions

More info: Rules | Cursor Docs

It’d also help to see:

  • A specific example of generated code that shows this issue
  • Which model you’re using
  • What prompt or request leads to these results

That’ll help us understand the pattern better and potentially improve code generation for your case.