Skip to content

Instantly share code, notes, and snippets.

@ditpoo
Last active March 11, 2025 11:17
Show Gist options
  • Save ditpoo/fe3d2955f59cee83ae8426fe2c24adcd to your computer and use it in GitHub Desktop.
Save ditpoo/fe3d2955f59cee83ae8426fe2c24adcd to your computer and use it in GitHub Desktop.
Sharing best practices I discovered/found for coding using ai based code generation

Sharing best practices I discovered/found for coding using AI based code generation

  1. Provide code base/project details and up-to-date context.
  2. Separation of concerns in different modules.
  3. Create implementation details for each PR, maintain implementation docs.
  4. Generate small, focused chunks of code (< 1k lines).
  5. Keep functions concise and small.
  6. Comment every function; add context before AI generation.
  7. Keep those comments updated with every change on that code
  8. Make sure the generated code is modular and easy to refactor.
  9. Lint all code, remove unused references.
  10. Review, refine, and iterate on every AI generation.
  11. Use AI code as a draft, finalize with human oversight.
  12. Always create human written test or don't use test in initial phase/draft.
  13. Use structured logging to debug generated code.

Things that provide the most improvement on quality of generated code

  • Small, focused generation (< 1k lines).
  • Provide it with quality context/details for generation.
  • Use generated code as a draft.
  • Review, refine, and iterate on every generation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment