Find configuration sprawl - duplicated constants, types, and values that should be centralized
Find and report configuration sprawl across the codebase. Configuration sprawl occurs when the same value, constant, type, or configuration is defined in multiple places instead of being imported from a single source of truth.
Configuration sprawl leads to:
Every piece of configuration should have exactly one canonical source. Consumers import from that source. If you find the same thing defined twice, one of them shouldn't exist.
Before searching for sprawl, understand where configuration SHOULD live:
Check for a shared types package (e.g., packages/types, @company/types)
Check for config files in feature directories
config.ts filesReview CLAUDE.md or similar for documented conventions
Look for these general categories. The specific items will vary by codebase.
Search for the same constant value appearing in multiple files:
- String literals that look like configuration
- Numeric values that appear repeatedly (temperatures, timeouts, limits)
- Arrays/enums that define valid values for something
Red flag: Same string/number appears in 3+ files, or a local const SOMETHING = when a shared package exports it.
Search for type definitions that appear in multiple places:
- interface SomeName { ... } in multiple files
- type SomeName = ... in multiple files
- Types that exist in a shared package but are redeclared locally
Red flag: grep -r "interface TypeName" returns multiple files.
Search for string literals used as discriminators or configuration:
- Status values: "active", "pending", "failed"
- Type discriminators: "user", "admin", "system"
- Mode flags: "on", "off", "auto"
- Feature identifiers in conditionals
Red flag: Same string literal appears in multiple files without a shared constant.
Search for exports that just re-export from somewhere else:
- export { X } from "./other-file"
- export type { X } from "./other-file"
Red flag: Consumers import from A, which re-exports from B. Why not import from B directly?
Search for configuration in test/eval directories that duplicates production config:
- Model IDs hardcoded in tests instead of imported from production config
- Prompts/schemas copied into test fixtures
- Constants redefined for "testing purposes"
Red flag: Test and production use different values for the same concept.
For each potential sprawl issue:
For each finding, report:
## [SEVERITY] [Brief title]
**Issue**: [What's duplicated and why it's a problem]
**Files**:
- `path/to/file1.ts:line` - [what it defines]
- `path/to/file2.ts:line` - [what it defines]
**Canonical source**: [Where this should live]
**Fix**:
1. [Step to centralize]
2. [Step to update consumers]
These are examples of grep/glob patterns to find sprawl. Adapt to your codebase:
# Find potential constant duplication
grep -r "const.*TYPES\s*=" --include="*.ts"
grep -r "export const.*=.*\[" --include="*.ts"
# Find potential type duplication
grep -r "^export interface" --include="*.ts" | sort | uniq -d
grep -r "^export type" --include="*.ts" | sort | uniq -d
# Find magic strings (common patterns)
grep -rE '"(active|pending|failed|enabled|disabled)"' --include="*.ts"
grep -rE 'status\s*===?\s*"' --include="*.ts"
# Find re-exports
grep -r "export.*from\s*['\"]\./" --include="*.ts"
# Find hardcoded model IDs (AI projects)
grep -rE '"[a-z]+:[a-z]+/[a-z]' --include="*.ts"
# Find hardcoded numbers that look like config
grep -rE "temperature:\s*0\.[0-9]" --include="*.ts"