# General Coding Instructions These instructions apply to all code generation regardless of language. ## Core Principles ### 1. Read Before Writing - **Always read relevant standards first** before generating code - Check `context/EDITORS.md` for editor conventions - Check `context/AGENTS_*.md` for language-specific patterns - Use provided templates and examples ### 2. Consistency Over Cleverness - Follow established patterns in the codebase - Match existing style and conventions - Use templates from AGENTS files - Don't introduce new patterns without discussion ### 3. Type Safety First - Use strict type checking (Go, Python, TypeScript) - Prefer compile-time errors over runtime errors - Document types explicitly - No `any` types without justification ### 4. LazyVim Integration - **LazyVim is the preferred editor** (see `context/EDITORS.md`) - Use LazyVim keybindings in examples - Reference which-key for discoverability - Provide VSCode alternatives when requested ## Code Quality Standards ### Documentation - All public APIs must be documented - Include examples in documentation - Explain "why" not just "what" - Keep documentation next to code ### Testing - Follow language-specific test patterns (AGENTS files) - Write tests before fixing bugs - Test edge cases and error conditions - Maintain high test coverage ### Error Handling - Never ignore errors - Provide context in error messages - Use language-idiomatic error handling - Log errors appropriately ### Security - Never commit secrets or credentials - Validate all inputs - Use parameterized queries (SQL) - Follow principle of least privilege ## Language-Specific Rules ### Go (`context/AGENTS_GO.md`) ```go // ✅ Accept interfaces, return concrete types func NewService(repo Repository) *Service { } // ✅ Use functional options for configuration func NewClient(opts ...Option) *Client { } // ✅ Context-aware functions func ProcessData(ctx context.Context, data []byte) error { } ``` ### Python (`context/AGENTS_PYTHON.md`) ```python # ✅ Type hints mandatory def process_data(items: list[Item]) -> Result: ... # ✅ Use uv for dependencies # uv add requests # uv run python main.py # ✅ Pydantic for validation class User(BaseModel): name: str email: EmailStr ``` ### TypeScript/Vue (`context/AGENTS_TYPESCRIPT_VUE.md`) ```vue ``` ### PowerShell (`context/AGENTS_POWERSHELL.md`) ```powershell # ✅ Multi-subscription by default function Get-AllResourceGroups { # Queries ALL subscriptions unless filtered } # ✅ Use Graph API over loops Search-AzGraph -Query "Resources | where type == 'Microsoft.Compute/virtualMachines'" ``` ### Bash (`context/AGENTS_BASH.md`) ```bash #!/bin/bash # ✅ Proper error handling set -euo pipefail # ✅ Use shellcheck # shellcheck disable=SC2086 # Only when necessary ``` ## Architecture Patterns ### Dependency Management - **Go**: Use Go modules, vendor if needed - **Python**: Use `uv` with `pyproject.toml` - **TypeScript**: Use pnpm or npm, lock files committed - **PowerShell**: Use `#Requires` statements ### Configuration - Use environment variables for secrets - Configuration files for non-secrets - Validate configuration at startup - Provide sensible defaults ### Logging - Use structured logging - Log levels: DEBUG, INFO, WARN, ERROR - Include context (request ID, user ID, etc.) - Never log sensitive data ## Git Commit Standards ### Commit Messages ``` ():