---
name: anti-hardcoding
description: Coding best practices — avoid hardcoding. Consider theme adaptation (dark/light), multi-language support (i18n), and variable dependencies when writing or modifying code.
---

When writing or modifying code, always check for hardcoding and apply these principles:

## Theme Adaptation (Dark/Light)

- Use CSS variables or design tokens for colors, not hex values
- Reference existing theme variables in `index.css` or component styles
- Never hardcode `#ffffff`, `#000000`, or specific colors in components
- Use semantic color names like `--color-bg`, `--color-text`, `--color-border`

## Multi-Language Support (i18n)

- Use i18n keys for user-facing strings, not hardcoded text
- Check if an i18n system exists in the project before adding new strings
- If no i18n system exists, extract strings to a constants file
- Never hardcode Chinese, English, or any language directly in components

## Variable Dependencies

- When modifying a value, check what depends on it downstream
- If variable A affects variable B, update both when changing A
- Use constants or config objects for values used in multiple places
- Avoid magic numbers — name them as constants with clear meaning

## Quick Checklist

Before submitting code changes:
1. Are there any hardcoded colors? → Use theme variables
2. Are there any hardcoded user-facing strings? → Use i18n or constants
3. Are there any magic numbers? → Extract to named constants
4. Did I break any dependent variables? → Verify downstream usage
