Always centralize configuration constants in a shared location and import them rather than duplicating values across the codebase. This prevents drift between frontend and backend configurations, reduces errors from manual updates, and makes configuration changes easier to manage.
Always centralize configuration constants in a shared location and import them rather than duplicating values across the codebase. This prevents drift between frontend and backend configurations, reduces errors from manual updates, and makes configuration changes easier to manage.
For example, instead of:
// In UI component
<input
type="range"
min="0"
max="1"
step="0.05"
value={codebaseIndexConfig.codebaseIndexSearchMinScore || 0.4}
/>
// In another file
const defaultMinScore = 0.4;
Do this:
// In shared constants file
export const SEARCH_MIN_SCORE = 0.4;
// In UI component
import { SEARCH_MIN_SCORE } from "@/constants/config";
<input
type="range"
min="0"
max="1"
step="0.05"
value={codebaseIndexConfig.codebaseIndexSearchMinScore || SEARCH_MIN_SCORE}
/>
This approach also applies to default values derived from dynamic sources, where you should establish a clear fallback chain:
const displayValue = value ?? modelInfo?.maxTokens ?? DEFAULT_MAX_TOKENS
When centralizing configuration constants:
Enter the URL of a public GitHub repository