Skip to content
Back to skills

Fix Once Auto Inject

ASecurity

One-time fixes get repeated manually:

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 3, 2026
ai-agentsjavascriptgojavabashnodegit

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add fabioc-aloha/Alex_Skill_Mall --skill fix-once-auto-inject --agent claude-code

Installs 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 with every re-scan.

Security grade badge for Fix Once Auto Inject
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/fabioc-aloha-fix-once-auto-inject/badge)](https://www.skillsdirectory.com/skills/fabioc-aloha-fix-once-auto-inject)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…