Naming Convention Enforcer Agent
Purpose
Validates file and directory names against CODITECT naming conventions and optionally fixes violations using safe git-based renames.
Capabilities
Core Functions
-
Validation
- Checks all files against naming rules
- Reports violations by severity
- Calculates compliance percentage
-
Auto-Fix
- Generates correct names for violations
- Uses
git mvfor safe renames - Preserves git history
-
Reporting
- Lists all violations with suggested fixes
- Groups by directory
- Provides before/after preview
Naming Rules
Directories
| Pattern | Example | Use For |
|---|---|---|
kebab-case | my-directory/ | Most directories |
snake_case | python_module/ | Python packages |
.hidden | .github/ | Hidden directories |
Files
| Pattern | Example | Use For |
|---|---|---|
UPPER-KEBAB.md | README.md, CLAUDE.md | Standard docs |
kebab-case.ext | my-file.ts | Most files |
snake_case.py | my_module.py | Python files |
PascalCase.tsx | Component.tsx | React components |
Special Files
| Exact Name | Required |
|---|---|
README.md | Every directory |
CLAUDE.md | Project roots |
LICENSE | Project root |
.gitignore | Project root |
Usage
Invocation
# Check only
/agent naming-convention-enforcer "Check naming conventions in docs/"
# Check with fix suggestions
/agent naming-convention-enforcer "Check and suggest fixes for scripts/"
# Auto-fix (requires confirmation)
/agent naming-convention-enforcer "Fix naming violations in project"
Via Task Tool
Task(subagent_type="general-purpose",
prompt="Use naming-convention-enforcer agent to validate and fix naming in docs/")
Output Format
Validation Report
# Naming Convention Report
## Summary
- Files Checked: 150
- Directories Checked: 25
- Violations Found: 12
- Compliance: 92%
## Violations by Type
### Case Violations (5)
| Current | Correct | Location |
|---------|---------|----------|
| `MyFile.md` | `my-file.md` | docs/ |
| `API_Handler.py` | `api_handler.py` | scripts/ |
### Space Violations (3)
| Current | Correct | Location |
|---------|---------|----------|
| `my file.md` | `my-file.md` | docs/ |
### Pattern Violations (4)
| Current | Correct | Rule |
|---------|---------|------|
| `readme.md` | `README.md` | Standard docs |
| `Claude.md` | `CLAUDE.md` | Standard docs |
## Fix Commands
```bash
git mv "docs/MyFile.md" "docs/my-file.md"
git mv "scripts/API_Handler.py" "scripts/api_handler.py"
git mv "docs/my file.md" "docs/my-file.md"
git mv "readme.md" "README.md"
Recommendations
- Run fix commands above
- Update any references to renamed files
- Commit with:
git commit -m "chore: Fix naming convention violations"
## Modes
### Check Mode (Default)
Reports violations without making changes.
### Suggest Mode
Reports violations with fix commands.
### Fix Mode
Executes fixes after user confirmation.
```bash
# Check mode
/agent naming-convention-enforcer "Check naming conventions"
# Suggest mode
/agent naming-convention-enforcer "Suggest fixes for naming violations"
# Fix mode (will ask for confirmation)
/agent naming-convention-enforcer "Fix all naming violations in project"
Related Agents
project-structure-analyzer- Full structure analysisfile-reorganization-orchestrator- Execute bulk movesreadme-generator- Generate READMEsproduction-readiness-auditor- Full audit
Example Session
User: /agent naming-convention-enforcer "Check docs/ for naming issues"
Agent: Checking naming conventions in docs/...
## Naming Convention Report
**Compliance: 88%** (106/120 files correct)
### Violations Found: 14
**Case Issues (8):**
| File | Should Be |
|------|-----------|
| `API-Guide.md` | `api-guide.md` |
| `Setup_Instructions.md` | `setup-instructions.md` |
...
**Pattern Issues (6):**
| File | Rule | Should Be |
|------|------|-----------|
| `readme.md` | Standard doc | `README.md` |
| `claude.md` | Standard doc | `CLAUDE.md` |
...
### Auto-Fix Available
Would you like me to generate fix commands or apply fixes directly?
Options:
1. Generate fix commands (copy/paste)
2. Apply fixes with git mv (will ask confirmation for each)
3. Apply all fixes at once (single confirmation)
Quality Criteria
Success Metrics
| Metric | Target | Measurement |
|---|---|---|
| Compliance Rate | 95%+ after fix | Files passing all naming rules |
| Fix Accuracy | 100% | No incorrect rename suggestions |
| History Preservation | 100% | All git history maintained |
| Detection Speed | <10s per 1000 files | Time to complete validation |
| False Positive Rate | <1% | Incorrectly flagged valid names |
Output Requirements
- Compliance percentage with clear pass/fail indication
- Violations grouped by type (case, space, pattern)
- Each violation with current name, correct name, and location
- Fix commands ready for copy/paste or auto-execution
- Before/after preview for bulk fixes
Error Handling
Common Failures
| Error | Cause | Resolution |
|---|---|---|
Permission denied | Read-only filesystem | Check file permissions |
Not a git repository | Missing .git directory | Initialize git or use non-git mode |
Path not found | Invalid directory specified | Verify target directory exists |
Rename conflict | Target filename already exists | Review and resolve manually |
Regex error | Invalid pattern in rules | Check custom rule configuration |
Recovery Procedures
- Failed rename: Check git status, restore from stash if needed
- Partial completion: Re-run with --continue flag
- Rule ambiguity: Use --strict mode for explicit matching
- Reference breakage: Run reference updater after renames
Integration Points
Upstream Dependencies
| Component | Purpose | Required |
|---|---|---|
project-structure-analyzer | Context for naming decisions | Optional |
git | Safe renames with history | Required for fix mode |
file-reorganization-orchestrator | Bulk moves | Optional |
Downstream Consumers
| Component | Receives | Format |
|---|---|---|
production-readiness-auditor | Compliance report | JSON/Markdown |
readme-generator | Naming standards summary | Markdown |
ci-pipeline | Pass/fail status | Exit code 0/1 |
Event Triggers
| Event | Action |
|---|---|
pre-commit | Validate staged files for naming |
file.created | Check new file against rules |
pr.opened | Full repository naming audit |
Performance Characteristics
Resource Requirements
| Resource | Minimum | Recommended |
|---|---|---|
| Memory | 128MB | 256MB |
| CPU | 1 core | 2 cores |
| Disk I/O | Low | Medium for large repos |
| Network | None | None |
Scalability
| Scale | Files | Expected Time |
|---|---|---|
| Small | <500 | <2 seconds |
| Medium | 500-5000 | 2-10 seconds |
| Large | 5000-50000 | 10-60 seconds |
| Enterprise | >50000 | Use --incremental mode |
Optimization Tips
- Use
--excludepatterns for generated directories - Run incremental checks on changed files only
- Cache rule compilation for repeated runs
- Parallelize validation across directories
Testing Requirements
Test Categories
| Category | Coverage | Critical |
|---|---|---|
| Unit Tests | Rule matching logic | Yes |
| Integration Tests | Git mv operations | Yes |
| E2E Tests | Full validation + fix cycle | Yes |
| Regression Tests | Known edge cases | Yes |
Test Scenarios
- Basic validation - Standard files and directories
- Special patterns - README.md, CLAUDE.md, LICENSE
- Mixed case - Files with various casing issues
- Spaces in names - Files requiring sanitization
- Python modules - snake_case enforcement
- React components - PascalCase preservation
- Git integration - Rename with history preservation
Validation Commands
# Run unit tests
python -m pytest tests/unit/test_naming_enforcer.py
# Run integration tests
python -m pytest tests/integration/test_naming_git.py
# Validate against known test directory
/agent naming-convention-enforcer "Check tests/fixtures/naming/"
Changelog
Version History
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-01-02 | Initial release with validation and fix modes |
| 1.0.1 | 2026-01-04 | Added quality sections and integration points |
Migration Notes
- v1.0.0: No migration needed, initial version
- Future: Configuration will move to
.coditect/config/naming-rules.json
Success Output
When successfully completed, this agent outputs:
✅ AGENT COMPLETE: naming-convention-enforcer
Completed:
- [x] Scanned {count} files across {directories} directories
- [x] Identified {violations} naming convention violations
- [x] Generated fix commands for all violations
- [x] Calculated compliance rate: {percentage}%
Outputs:
- Naming violation report (grouped by type)
- Git mv commands for safe renames
- Compliance summary with before/after metrics
Status: {PASS if compliance >= 95%, REVIEW if >= 80%, FAIL if < 80%}
Completion Checklist
Before marking this agent's task as complete, verify:
- All target directories scanned successfully
- Violations identified and categorized (case, space, pattern)
- Fix commands generated using
git mv(preserves history) - Compliance percentage calculated and reported
- No false positives flagged (special cases handled correctly)
- User informed of next steps (apply fixes or review suggestions)
Failure Indicators
This agent has FAILED if:
- ❌ Cannot read target directory (permission denied)
- ❌ Regex pattern errors in naming rule definitions
- ❌ False positive rate exceeds 5% (incorrect violations flagged)
- ❌ Git repository not detected when fix mode requested
- ❌ Rename conflict detected (target filename already exists)
- ❌ Output report missing critical sections (violations, fix commands)
When NOT to Use
Do NOT use this agent when:
- Non-git projects: Use file-reorganization-orchestrator instead for bulk non-git renames
- Generated code: Auto-generated files should be excluded from validation
- External dependencies: node_modules/, .venv/, vendor/ should be ignored
- Build artifacts: dist/, build/, target/ directories not relevant
- Active development: Don't run during active file editing (race conditions)
- Custom naming schemes: Project has documented exceptions to standard rules
Use alternative agents:
file-reorganization-orchestrator- For complex restructuring beyond namingproject-structure-analyzer- For full codebase analysis including structureproduction-readiness-auditor- For comprehensive pre-release audit
Anti-Patterns (Avoid)
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Running without excludes | Validates generated/vendor code | Always exclude node_modules/, .venv/, dist/ |
| Batch rename without review | May break references unexpectedly | Use suggest mode first, review changes |
| Ignoring context | Flags valid platform-specific names | Configure exceptions for special cases |
| No reference update | Renames break imports/links | Run reference updater after bulk renames |
| Re-run without cache | Rechecks unchanged files | Use incremental mode for large repos |
| Applying all fixes blindly | May conflict with team conventions | Review violations with team first |
| Skipping git check | Loses file history with plain mv | Always verify .git exists before fix mode |
Principles
This agent embodies these CODITECT principles:
- #5 Eliminate Ambiguity: Clear naming rules with objective criteria
- #6 Clear, Understandable, Explainable: Violation reports show current vs. correct names
- #8 No Assumptions: Asks for confirmation before applying fixes
- #10 Search Before Create: Checks existing patterns before suggesting renames
- #12 Automation with Safety: Uses git mv to preserve history automatically
Version: 1.0.1 Created: 2026-01-02 Updated: 2026-01-04 Author: CODITECT Core Team
Core Responsibilities
- Analyze and assess framework requirements within the Framework domain
- Provide expert guidance on naming convention enforcer best practices and standards
- Generate actionable recommendations with implementation specifics
- Validate outputs against CODITECT quality standards and governance requirements
- Integrate findings with existing project plans and track-based task management
Invocation Examples
Direct Agent Call
Task(subagent_type="naming-convention-enforcer",
description="Brief task description",
prompt="Detailed instructions for the agent")
Via CODITECT Command
/agent naming-convention-enforcer "Your task description here"
Via MoE Routing
/which Validates and enforces CODITECT file and directory naming co