These rules apply to ALL projects regardless of language or framework.
- ❌ NEVER commit secrets, API keys, passwords, or credentials
- ✅ Use environment variables for all configuration
- ✅ Run secret scanning before commits:
gitleaks detect --no-git - ✅ Use secret management services (AWS Secrets Manager, 1Password)
Block editing of these files:
.env,.env.*credentials.json,secrets.yaml**/config/production.yml- Any file containing API keys or tokens
Before any commit:
# Scan for hardcoded secrets
gitleaks detect --no-git --source=.
# Check dependencies for vulnerabilities
# Python: pip-audit or safety
# Node.js: npm audit
# Go: govulncheck- Write tests FIRST (Test-Driven Development)
- Minimum code coverage: 80%
- Test edge cases and error conditions
- Use meaningful test names that describe behavior
- Follow existing patterns in the codebase
- Self-documenting code with clear variable/function names
- Comments explain WHY, not WHAT
- Keep functions small (<50 lines) and single-purpose
- Handle ALL errors explicitly
- Never use bare
except:orcatch (e) {} - Log errors with context (request ID, user ID, operation)
- Return meaningful error messages to users
- Use Conventional Commits format:
feat: add user authenticationfix: prevent duplicate ordersdocs: update API documentationrefactor: simplify payment logic
- Reference issue numbers:
feat: add logout (#123) - Keep commits atomic (one logical change per commit)
feature/short-descriptionfix/bug-descriptionrefactor/area-being-refactored
Always run:
# 1. Run tests
npm test # or pytest, go test, etc.
# 2. Check git diff
git diff --cached
# 3. Verify no secrets
gitleaks detect --no-git- Write specifications BEFORE implementation
- Use formal specs: OpenAPI, JSON Schema, Gherkin
- Link code to specification IDs for traceability
When working in specialized areas, load additional rules:
- API work: Load API design rules
- Security changes: Load security-specific rules
- Database migrations: Load database rules
- Ask clarifying questions before major changes
- Explain non-obvious implementation decisions
- Propose alternatives when requirements are ambiguous
- Never log PII (emails, names, addresses)
- Redact sensitive data in error messages
- Follow GDPR/CCPA data handling requirements
- Log significant actions (authentication, data changes)
- Include: timestamp, user ID, action, result
- Retention: 90 days minimum for audit logs
- Update README.md when adding features
- Document environment variables in
.env.example - Keep API documentation current (OpenAPI/Swagger)
- Pin versions in production (
package-lock.json,requirements.txt) - Review security advisories before upgrading
- Test upgrades in staging before production
Questions about these rules? Contact: dev-leads@yourorg.com
Rule updates: Create PR in ai-rules-central repository