# Code Generation Patterns ## Function Implementation ``` Write a [language] function: - Input: [params with types] - Output: [return type] - Behavior: [logic] Requirements: - Edge cases: [list] - Error handling: [approach] - Performance: O([complexity]) ``` ## Code Review ``` Review for: 1. Bugs/logic errors 2. Security vulnerabilities 3. Performance issues 4. Style violations 5. Missing edge cases Format: Issue, line number, severity, fix. ``` ## Refactoring ``` Refactor to: - [Improvement goal] - Maintain backward compatibility - Keep public API - Add comments for complex logic Show before/after. ``` ## Debugging ``` [Error message/behavior] [Relevant code] [When it occurs] Analyze: 1. Root cause 2. Why it happens 3. Fix with explanation 4. Prevention strategy ``` ## Test Generation ``` Generate tests for [function/class]: - Framework: [jest/pytest/etc] - Coverage: happy path, edge cases, errors - Include: setup, assertion, cleanup - Mock: [external dependencies] ``` ## Documentation ``` Document this [function/class/API]: - Format: [JSDoc/docstring/OpenAPI] - Include: description, params, returns, examples - Note: edge cases, errors, deprecations ```