Rules for AI

December 2024. After the chaos with Cline I realized - need rules.

Made a document: coding-style.md. Everything's there: folder structure, file naming, how to write functions, which patterns to use, which not.

Before each chat I share this document. AI reads and follows. Not always perfect, but much better than without rules.

What's in the document

  • Project structure: where controllers go, where services, where types
  • Naming: camelCase for functions, PascalCase for classes
  • Imports: external first, then internal, then types
  • Async/await everywhere, no callbacks
  • Error handling: try-catch in controllers, throw in services
  • Comments: only for complex logic, not for obvious things

Result

AI stopped making up its own structure. Code became consistent. Less time refactoring after generation.

The document grows. Now it's 3 pages. Every time AI does something wrong - I add a rule.

← Back to blog