One-time fixes get repeated manually:
Scanned 9/3/2026
Install to Claude Code
npx -y skills add fabioc-aloha/Alex_Skill_Mall --skill fix-once-auto-inject --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Fix Once Auto Inject?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/fabioc-aloha-fix-once-auto-inject)More formats (shields.io, HTML) on the badges page.
---
name: fix-once-auto-inject
description: "One-time fixes get repeated manually:"
lastReviewed: 2026-04-30
---
# Fix-Once + Auto-Inject-Future
## The Problem
One-time fixes get repeated manually:
- "Add the missing import to every new file"
- "Remember to set the flag when creating services"
- Relies on human memory → fails over time
## The Solution
Pair an idempotent one-time fix with a build-time auto-inject fallback.
### Prong 1: One-Time Fix Script
```javascript
// scripts/fix-missing-headers.cjs
const fs = require('fs');
const glob = require('glob');
const header = '// Copyright 2026 Company\n\n';
glob.sync('src/**/*.ts').forEach(file => {
const content = fs.readFileSync(file, 'utf8');
if (!content.startsWith('// Copyright')) {
fs.writeFileSync(file, header + content);
console.log(`Fixed: ${file}`);
}
});
```
Run once to fix existing files.
### Prong 2: Auto-Inject at Build
```javascript
// In build pipeline or git hook
const files = getChangedFiles();
files.filter(f => f.endsWith('.ts')).forEach(file => {
const content = fs.readFileSync(file, 'utf8');
if (!content.startsWith('// Copyright')) {
// Auto-fix or fail the build
console.error(`Missing header: ${file}`);
process.exit(1);
}
});
```
### Git Hook Version
```bash
#!/bin/bash
# .git/hooks/pre-commit
for file in $(git diff --cached --name-only | grep '\.ts$'); do
if ! head -1 "$file" | grep -q "Copyright"; then
echo "Missing copyright header: $file"
exit 1
fi
done
```
## Pattern
```
┌─────────────────────────────────────┐
│ Fix existing files (one-time) │
│ node scripts/fix-all.cjs │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Enforce on new files (ongoing) │
│ build hook / pre-commit / CI │
└─────────────────────────────────────┘
```
## Verification
1. Running fix script on already-fixed files is idempotent
2. Creating a new file without the fix fails the hook
3. No manual enforcement needed after setup
## When to Apply
- License headers
- Required imports
- Configuration defaults
- Any "every file must have X" rule
## Tags
`build` `automation` `enforcement` `hooks`
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!