repo-hygiene — Repository Health Check
A structured, periodic health check for repositories. Run anytime to detect drift,
accumulation of tech debt, and configuration issues before they become problems.
Not a release gate. For pre-release checks, use the pre-release skill instead.
This skill is for ongoing maintenance — run it weekly, after major refactors, when
onboarding to a repo, or whenever things feel "off".
When to Use
- Onboarding to a new (or forgotten) repo — "what shape is this in?"
- Weekly/monthly maintenance sweep
- After a large refactor or dependency upgrade
- Before starting a new feature sprint
- When CI starts failing mysteriously
- After a team member leaves and you inherit their repo
Supported Stacks
| Stack |
Package manager |
Detected by |
| Node.js / TypeScript |
npm |
package.json + package-lock.json |
| Python |
uv / pip |
pyproject.toml or requirements.txt |
| Go |
go modules |
go.mod |
Detect the stack from the project root. Multiple stacks in one repo is fine — run
applicable checks for each. If the stack isn't listed, skip stack-specific checks
and run the universal ones (git, CI, docs, security).
The Workflow
Step 0: Detect Project
# What are we working with?
ls package.json pyproject.toml go.mod 2>/dev/null
git rev-parse --show-toplevel
Determine: stack(s), git remote, default branch, CI system (GitHub Actions, GitLab CI, etc.).
Step 1: Dependency Health
Node.js / npm
| # |
Check |
Command |
Severity |
| D1 |
Known vulnerabilities |
npm audit --json |
🔴 critical/high = Fix Now, moderate = Fix Soon |
| D2 |
Outdated dependencies |
npm outdated --json |
🟡 major bumps = Fix Soon, minor/patch = Info |
| D3 |
Unused dependencies |
npx depcheck --json |
🟡 Fix Soon |
| D4 |
Phantom dependencies (used but undeclared) |
npx depcheck --json → missing |
🔴 Fix Now |
| D5 |
Lockfile freshness |
See below |
🟡 Fix Soon |
| D6 |
Duplicate dependencies |
npm ls --all --json 2>/dev/null | grep -c '"deduped"' |
ℹ️ Info |
D5 — Lockfile freshness check:
# package.json changed more recently than lockfile?
LOCK_DATE=$(git log -1 --format=%ct -- package-lock.json 2>/dev/null || echo 0)
PKG_DATE=$(git log -1 --format=%ct -- package.json 2>/dev/null || echo 0)
if [ "$PKG_DATE" -gt "$LOCK_DATE" ]; then
echo "⚠️ package.json modified after lockfile — run npm install"
fi
How to fix:
- D1:
npm audit fix for compatible fixes; npm audit fix --force for breaking (review changes). For stubborn advisories: check if the vuln is reachable, or override in package.json overrides.
- D2:
npm update for minor/patch; npm install <pkg>@latest for major (check changelogs).
- D3:
npm uninstall <pkg> for each unused dep.
- D4:
npm install <pkg> for each missing dep.
- D5:
npm install to regenerate lockfile, commit it.
- D6:
npm dedupe then verify tests pass.
Python (uv / pip)
| # |
Check |
Command |
Severity |
| D1 |
Known vulnerabilities |
pip-audit --format=json |
🔴 Fix Now |
| D2 |
Outdated dependencies |
uv pip list --outdated or pip list --outdated --format=json |
🟡 Fix Soon |
| D3 |
Unused dependencies |
deptry . --json (if available) |
🟡 Fix Soon |
| D5 |
Lockfile freshness |
Compare uv.lock vs pyproject.toml timestamps |
🟡 Fix Soon |
How to fix:
- D1:
uv pip install --upgrade <pkg> for each vulnerable package. Check advisories for minimum safe version.
- D2:
uv pip install --upgrade <pkg> per package, or uv lock --upgrade for all.
- D3: Remove from
[project.dependencies] in pyproject.toml, then uv sync.
- D5:
uv lock && uv sync.
Go
| # |
Check |
Command |
Severity |
| D1 |
Known vulnerabilities |
govulncheck ./... |
🔴 Fix Now |
| D2 |
Outdated dependencies |
go list -m -u all |
🟡 Fix Soon |
| D3 |
Unused dependencies |
go mod tidy -v (reports removed) |
🟡 Fix Soon |
How to fix:
- D1:
go get <module>@latest for vulnerable deps, then go mod tidy.
- D2:
go get -u ./... for all, or go get <module>@latest selectively.
- D3:
go mod tidy removes unused; commit go.mod and go.sum.
Step 2: Git Hygiene
| # |
Check |
Command |
Severity |
| G1 |
Stale local branches (merged) |
git branch --merged main | grep -v '^\*|main|develop' |
🟡 Fix Soon |
| G2 |
Stale remote branches (merged) |
git branch -r --merged origin/main | grep -v 'HEAD|main|develop' |
🟡 Fix Soon |
| G3 |
Large files in repo |
See below |
🟡 Fix Soon (🔴 if >10MB) |
| G4 |
.gitignore completeness |
See below |
🟡 Fix Soon |
| G5 |
Untracked files that should be ignored |
git status --porcelain | grep '^??' — look for build artifacts, IDE files, env files |
ℹ️ Info |
| G6 |
Uncommitted changes |
git status --porcelain |
ℹ️ Info |
G3 — Large files check:
# Top 10 largest tracked files
git ls-files -z | xargs -0 -I{} git log --diff-filter=A --format='%H' -1 -- '{}' | head -20
# Simpler: just check current tree
git ls-files -z | xargs -0 du -sh 2>/dev/null | sort -rh | head -10
G4 — .gitignore completeness:
Must include (per stack):
- Universal:
.env, .env.*, *.local, .DS_Store, Thumbs.db, *.swp, .idea/, .vscode/ (or be deliberate about tracking it)
- Node:
node_modules/, dist/, build/, coverage/, .turbo/, .next/
- Python:
__pycache__/, *.pyc, .venv/, venv/, .mypy_cache/, .pytest_cache/, *.egg-info/
- Go: binary name (check
go build -o), vendor/ (if not vendoring)
How to fix:
- G1:
git branch -d <branch> for each merged local branch.
- G2:
git push origin --delete <branch> for each merged remote branch. Be careful — confirm with team.
- G3: For files that shouldn't be tracked: add to
.gitignore, git rm --cached <file>. For files already in history: git filter-repo or BFG Repo-Cleaner (destructive — confirm first).
- G4: Add missing patterns to
.gitignore. Use a generator like gitignore.io as a starting point.
- G5: Either add to
.gitignore or git add if they should be tracked.
Step 3: CI/CD Health
Skip if no CI configuration found.
| # |
Check |
Command |
Severity |
| C1 |
Workflow files exist |
ls .github/workflows/*.yml 2>/dev/null |
ℹ️ Info |
| C2 |
Actions pinned by SHA |
grep -rE 'uses: [^@]+@v[0-9]' .github/workflows/ — should return nothing |
🟡 Fix Soon |
| C3 |
Least-privilege permissions |
Scan for permissions: blocks; flag write-all or missing job-level perms |
🟡 Fix Soon |
| C4 |
No secret leaks in workflows |
Check for echo ${{ secrets.* }}, secret in $GITHUB_OUTPUT/$GITHUB_ENV |
🔴 Fix Now |
| C5 |
Deprecated actions |
Check for known deprecated: actions/create-release@v1, set-output commands, ::set-env |
🟡 Fix Soon |
| C6 |
Node/Python version matches project |
Compare workflow matrix with engines, .nvmrc, pyproject.toml [requires-python] |
🟡 Fix Soon |
How to fix:
- C2: Replace
uses: actions/checkout@v4 with uses: actions/checkout@<full-sha>. Find SHA: gh api repos/actions/checkout/git/ref/tags/v4 --jq .object.sha or check the releases page.
- C3: Add explicit
permissions: at job level. Start with contents: read and add only what's needed.
- C4: Remove secret interpolation. Use
environment: blocks or write to files with masking.
- C5: Replace deprecated actions with current equivalents.
set-output → $GITHUB_OUTPUT file.
- C6: Align versions. Use
.nvmrc or engines as the source of truth.
Step 4: Code Quality Drift
| # |
Check |
Command |
Severity |
| Q1 |
TODO/FIXME/HACK count |
git grep -ciE '(TODO|FIXME|HACK)' -- '*.ts' '*.js' '*.py' '*.go' ':!node_modules' ':!vendor' ':!.venv' |
ℹ️ Info (🟡 if >20) |
| Q2 |
console.log in src (JS/TS) |
git grep -c 'console\.log' -- 'src/**/*.ts' 'src/**/*.js' ':!*.test.*' ':!*.spec.*' |
🟡 Fix Soon |
| Q3 |
Disabled/skipped tests |
git grep -cE '(it\.skip|test\.skip|describe\.skip|xit|xdescribe|@pytest\.mark\.skip|t\.Skip)' -- '*.test.*' '*.spec.*' '*_test.*' '*_test.go' |
🟡 Fix Soon |
| Q4 |
Lint passes |
npm run lint / ruff check . / golangci-lint run |
🟡 Fix Soon |
| Q5 |
Tests pass |
npm test / pytest / go test ./... |
🔴 Fix Now |
| Q6 |
Build succeeds |
npm run build / uv build / go build ./... |
🔴 Fix Now |
| Q7 |
Type errors (TS) |
npx tsc --noEmit |
🟡 Fix Soon |
| Q8 |
Dead exports (TS) |
npx ts-prune 2>/dev/null | grep -v '(used in module)' |
ℹ️ Info |
How to fix:
- Q1: Triage each TODO — either do it, create an issue/task for it, or remove it if obsolete.
- Q2: Replace with a proper logger, or remove debug logging.
grep -rn 'console.log' src/ to find them.
- Q3: Either fix the underlying issue and un-skip, or delete the test if the feature was removed.
- Q4–Q7: Fix the errors. Run the tool, address each issue.
- Q8: Remove unused exports, or add
// ts-prune-ignore-next if they're part of the public API.
Step 5: Documentation Freshness
| # |
Check |
Command |
Severity |
| F1 |
README.md exists |
File check |
🔴 Fix Now |
| F2 |
README freshness vs. source |
Compare git log -1 --format=%cr -- README.md vs git log -1 --format=%cr -- src/ |
🟡 if src is >30 days newer |
| F3 |
CHANGELOG exists |
File check |
🟡 Fix Soon (for published packages) |
| F4 |
Broken internal links |
See below |
🟡 Fix Soon |
| F5 |
LICENSE file present |
File check |
🔴 Fix Now |
| F6 |
LICENSE matches package metadata |
Compare LICENSE text with package.json license / pyproject.toml license |
🟡 Fix Soon |
| F7 |
AGENTS.md references valid paths |
If .pi/AGENTS.md exists, check that referenced files/dirs exist |
🟡 Fix Soon |
F4 — Broken link check:
# Find markdown links and verify targets exist
grep -roE '\[([^]]+)\]\(([^)]+)\)' *.md docs/**/*.md 2>/dev/null | \
grep -v 'http' | \
while IFS= read -r line; do
# Extract path from markdown link
path=$(echo "$line" | sed 's/.*](\([^)]*\)).*/\1/' | sed 's/#.*//')
if [ -n "$path" ] && [ ! -e "$path" ]; then
echo "BROKEN: $line"
fi
done
How to fix:
- F1: Write a README with: what it does, how to install, how to use, prerequisites, license.
- F2: Review README against current code — update examples, API docs, feature lists.
- F3: Add a CHANGELOG.md. Consider
@changesets/cli for automated generation (see pre-release skill).
- F4: Update or remove broken links.
- F5: Add a LICENSE file. Use choosealicense.com if unsure.
- F6: Make LICENSE file and metadata agree.
- F7: Update AGENTS.md to reflect current project structure.
Step 6: Configuration Consistency
| # |
Check |
How |
Severity |
| X1 |
EditorConfig present |
.editorconfig exists |
ℹ️ Info |
| X2 |
Strict mode (TS) |
tsconfig.json → "strict": true |
🟡 Fix Soon |
| X3 |
Formatter configured |
.prettierrc / ruff.toml / gofmt (built-in) |
🟡 Fix Soon |
| X4 |
Linter configured |
.eslintrc* or eslint.config.* / ruff.toml / golangci-lint config |
🟡 Fix Soon |
| X5 |
Engine constraints match CI |
package.json engines vs CI matrix; pyproject.toml requires-python vs CI |
🟡 Fix Soon |
| X6 |
.nvmrc / .python-version matches |
Compare with engines / requires-python / CI config |
ℹ️ Info |
How to fix:
- X1: Add
.editorconfig. Minimal: root = true, [*] block with indent_style, indent_size, end_of_line, insert_final_newline.
- X2: Set
"strict": true in tsconfig.json. Fix resulting type errors (usually worth it).
- X3–X4: Add config files. Use the project's existing style as a baseline.
- X5–X6: Pick one source of truth (recommend
engines / requires-python) and align everything else.
Step 7: Security Posture
Lightweight security checks for ongoing hygiene. For the full pre-release security audit
(gitleaks, trufflehog, workflow audit), use the pre-release skill.
| # |
Check |
Command |
Severity |
| S1 |
No tracked .env or .local files |
git ls-files '*.env' '*.env.*' '*.local' '*.local.*' '.env' '.env.local' |
🔴 Fix Now |
| S2 |
.env.example exists (if .env in .gitignore) |
File check |
🟡 Fix Soon |
| S3 |
No hardcoded secrets in source |
git grep -iE '(api[_-]?key|secret|password|token)\s*[:=]\s*["\x27][^"\x27]{8,}' -- ':!*.lock' ':!node_modules' ':!*.example' ':!*.sample' |
🔴 Fix Now |
| S4 |
Secrets scanning config present |
.gitleaks.toml or pre-commit hooks |
ℹ️ Info |
| S5 |
No broad file permissions |
Check for chmod 777 or 0777 in scripts |
🔴 Fix Now |
How to fix:
- S1:
git rm --cached <file>, add to .gitignore, commit. If the file contained real secrets, rotate them immediately — they're in git history.
- S2: Create
.env.example with placeholder values (<REPLACE_ME>) for every var in .env.
- S3: Move secrets to env vars or a secrets manager. Replace in code with
process.env.VAR / os.environ["VAR"].
- S4: Add
.gitleaks.toml (even a minimal one enables CI scanning). Or add gitleaks to pre-commit hooks.
- S5: Use least-privilege permissions (
644 for files, 755 for executables).
Step 8: Project Metadata
| # |
Check |
How |
Severity |
| M1 |
Required package fields |
name, version, description, license in package.json / pyproject.toml |
🟡 Fix Soon |
| M2 |
Repository URL set |
repository field in package metadata |
🟡 Fix Soon |
| M3 |
Keywords present |
keywords array |
ℹ️ Info |
| M4 |
FUNDING.yml (public repos) |
.github/FUNDING.yml exists |
ℹ️ Info |
| M5 |
Pi package compliance |
If ships skills/extensions: pi-package keyword, pi manifest, files includes skill dirs |
🟡 Fix Soon (if applicable) |
How to fix:
- M1–M3: Add the missing fields to
package.json or pyproject.toml.
- M4: Create
.github/FUNDING.yml with github: <username>.
- M5: See pi package docs for required fields.
Baseline Tracking
Save a baseline after each run to detect drift over time. Store at .pi/hygiene-baseline.json:
{
"timestamp": "2026-02-14T23:00:00Z",
"stack": ["node"],
"scores": {
"dependencies": { "status": "healthy", "vulns": 0, "outdated": 3, "unused": 0 },
"git": { "status": "healthy", "stale_branches": 0, "large_files": 0 },
"ci": { "status": "warning", "unpinned_actions": 2, "permission_issues": 0 },
"quality": { "status": "healthy", "todos": 5, "skipped_tests": 0, "lint_clean": true },
"docs": { "status": "warning", "readme_stale_days": 45, "broken_links": 1 },
"config": { "status": "healthy", "strict_ts": true, "formatter": true, "linter": true },
"security": { "status": "healthy", "tracked_env": 0, "hardcoded_secrets": 0 },
"metadata": { "status": "healthy", "complete": true }
},
"overall": "7/10"
}
On subsequent runs, compare with baseline and flag regressions:
📉 Dependencies: 0 → 3 vulnerabilities (regression since last check)
📈 Quality: 15 → 5 TODOs (improvement!)
→ CI: unchanged — 2 unpinned actions remain
When the user approves the report, offer to update the baseline.
Report Format
Present the final report as a health scorecard:
# Repo Health: <project-name>
## Score: 7/10 — GOOD
## Stack: Node.js + TypeScript
## Last check: 2026-01-15 (30 days ago) | Baseline: 6/10 📈
### 🔴 Fix Now (2)
| # | Category | Issue | Fix |
|---|----------|-------|-----|
| S1 | Security | `.env.local` tracked in git | `git rm --cached .env.local` |
| D1 | Deps | 2 high-severity npm audit findings | `npm audit fix` |
### 🟡 Fix Soon (4)
| # | Category | Issue | Fix |
|---|----------|-------|-----|
| D2 | Deps | 8 outdated packages (2 major) | `npm outdated` → upgrade |
| C2 | CI | 3 actions not pinned by SHA | Pin to commit SHA |
| F2 | Docs | README 45 days behind source | Review and update |
| Q3 | Quality | 2 skipped tests | Fix or remove |
### 🟢 Healthy (12)
- ✅ Dependencies: no unused, no phantom, lockfile fresh
- ✅ Git: clean tree, no stale branches, no large files
- ✅ Code: lint clean, build passes, tests pass, strict TS
- ✅ Config: EditorConfig, Prettier, ESLint all configured
- ✅ Security: no tracked secrets, .env.example present
- ✅ Metadata: all fields present, license matches
### 📊 Trends (vs. baseline 2026-01-15)
| Category | Then | Now | Trend |
|----------|------|-----|-------|
| Vulnerabilities | 0 | 2 | 📉 |
| Outdated deps | 5 | 8 | 📉 |
| TODOs | 15 | 8 | 📈 |
| Skipped tests | 0 | 2 | 📉 |
### Recommendations
1. **Immediate**: Fix the 2 security/vulnerability items above
2. **This week**: Pin CI actions and update stale README
3. **Ongoing**: Address skipped tests and outdated deps in next sprint
Use your project's task tracking to schedule these items.
Scoring
Calculate the score from check results:
| Result |
Points deducted |
| Each 🔴 Fix Now |
−1.5 |
| Each 🟡 Fix Soon |
−0.5 |
| ℹ️ Info |
0 |
Start at 10, apply deductions, floor at 0. Round to nearest integer.
| Score |
Label |
| 9–10 |
🟢 EXCELLENT |
| 7–8 |
🟢 GOOD |
| 5–6 |
🟡 FAIR |
| 3–4 |
🟠 NEEDS WORK |
| 0–2 |
🔴 POOR |
Auto-Fix Offers
After presenting the report, offer to fix issues that are safe and mechanical.
Always present what will be done and get confirmation before executing.
Safe to offer (low risk, reversible)
- Delete merged local branches (
git branch -d)
- Run
npm audit fix (compatible fixes only, not --force)
- Run
npm dedupe / go mod tidy
- Add missing
.gitignore patterns
- Add
.editorconfig from template
- Remove
console.log from source files
- Create
.env.example from .env (with values replaced by <REPLACE_ME>)
- Add missing
package.json fields (description, repository, keywords)
- Create
.github/FUNDING.yml
Offer with warning (confirm carefully)
- Delete merged remote branches (
git push origin --delete)
- Run
npm audit fix --force (may have breaking changes)
- Major dependency upgrades
- Enable TypeScript strict mode (may produce many errors)
- Update CI action pinning (must verify correct SHAs)
Never auto-fix (explain, let user decide)
- Removing tracked
.env files (may need secret rotation)
- Rewriting git history (BFG / filter-repo)
- Changing license files
- Modifying CI permissions model
- Removing hardcoded secrets (need to determine replacement strategy)
Tips
- Run early, run often. A monthly cadence catches drift before it compounds.
- Don't try to fix everything at once. Focus on 🔴 items first, batch 🟡 items into a maintenance sprint.
- Baseline tracking is your friend. Even if the score isn't perfect, trending upward means you're winning.
- Pair with pre-release. Run
repo-hygiene for ongoing health, pre-release when you're ready to ship. They complement each other — hygiene keeps the baseline high so pre-release has fewer surprises.
- New repos start clean. Run this right after
git init to establish a perfect baseline. It's easier to maintain 10/10 than to recover from 4/10.
1---2name: repo-hygiene3description: Periodic repository health check — dependencies, git, CI/CD, code quality, docs, security. Use when: onboarding to a repo, weekly maintenance, after big refactors, before audits, "is this repo in good shape?". Triggers: "repo hygiene", "health check", "repo health", "clean up repo", "maintenance check", "audit repo", "repo audit".4---56# repo-hygiene — Repository Health Check78A structured, periodic health check for repositories. Run anytime to detect drift,9accumulation of tech debt, and configuration issues before they become problems.1011**Not a release gate.** For pre-release checks, use the `pre-release` skill instead.12This skill is for ongoing maintenance — run it weekly, after major refactors, when13onboarding to a repo, or whenever things feel "off".1415## When to Use1617- Onboarding to a new (or forgotten) repo — "what shape is this in?"18- Weekly/monthly maintenance sweep19- After a large refactor or dependency upgrade20- Before starting a new feature sprint21- When CI starts failing mysteriously22- After a team member leaves and you inherit their repo2324## Supported Stacks2526| Stack | Package manager | Detected by |27|-------|----------------|-------------|28| Node.js / TypeScript | npm | `package.json` + `package-lock.json` |29| Python | uv / pip | `pyproject.toml` or `requirements.txt` |30| Go | go modules | `go.mod` |3132Detect the stack from the project root. Multiple stacks in one repo is fine — run33applicable checks for each. If the stack isn't listed, skip stack-specific checks34and run the universal ones (git, CI, docs, security).3536## The Workflow3738### Step 0: Detect Project3940```bash41# What are we working with?42ls package.json pyproject.toml go.mod 2>/dev/null43git rev-parse --show-toplevel44```4546Determine: stack(s), git remote, default branch, CI system (GitHub Actions, GitLab CI, etc.).4748### Step 1: Dependency Health4950#### Node.js / npm5152| # | Check | Command | Severity |53|---|-------|---------|----------|54| D1 | Known vulnerabilities | `npm audit --json` | 🔴 critical/high = Fix Now, moderate = Fix Soon |55| D2 | Outdated dependencies | `npm outdated --json` | 🟡 major bumps = Fix Soon, minor/patch = Info |56| D3 | Unused dependencies | `npx depcheck --json` | 🟡 Fix Soon |57| D4 | Phantom dependencies (used but undeclared) | `npx depcheck --json` → `missing` | 🔴 Fix Now |58| D5 | Lockfile freshness | See below | 🟡 Fix Soon |59| D6 | Duplicate dependencies | `npm ls --all --json 2>/dev/null \| grep -c '"deduped"'` | ℹ️ Info |6061**D5 — Lockfile freshness check:**6263```bash64# package.json changed more recently than lockfile?65LOCK_DATE=$(git log -1 --format=%ct -- package-lock.json 2>/dev/null || echo 0)66PKG_DATE=$(git log -1 --format=%ct -- package.json 2>/dev/null || echo 0)67if [ "$PKG_DATE" -gt "$LOCK_DATE" ]; then68 echo "⚠️ package.json modified after lockfile — run npm install"69fi70```7172**How to fix:**7374- D1: `npm audit fix` for compatible fixes; `npm audit fix --force` for breaking (review changes). For stubborn advisories: check if the vuln is reachable, or override in `package.json` `overrides`.75- D2: `npm update` for minor/patch; `npm install <pkg>@latest` for major (check changelogs).76- D3: `npm uninstall <pkg>` for each unused dep.77- D4: `npm install <pkg>` for each missing dep.78- D5: `npm install` to regenerate lockfile, commit it.79- D6: `npm dedupe` then verify tests pass.8081#### Python (uv / pip)8283| # | Check | Command | Severity |84|---|-------|---------|----------|85| D1 | Known vulnerabilities | `pip-audit --format=json` | 🔴 Fix Now |86| D2 | Outdated dependencies | `uv pip list --outdated` or `pip list --outdated --format=json` | 🟡 Fix Soon |87| D3 | Unused dependencies | `deptry . --json` (if available) | 🟡 Fix Soon |88| D5 | Lockfile freshness | Compare `uv.lock` vs `pyproject.toml` timestamps | 🟡 Fix Soon |8990**How to fix:**9192- D1: `uv pip install --upgrade <pkg>` for each vulnerable package. Check advisories for minimum safe version.93- D2: `uv pip install --upgrade <pkg>` per package, or `uv lock --upgrade` for all.94- D3: Remove from `[project.dependencies]` in `pyproject.toml`, then `uv sync`.95- D5: `uv lock && uv sync`.9697#### Go9899| # | Check | Command | Severity |100|---|-------|---------|----------|101| D1 | Known vulnerabilities | `govulncheck ./...` | 🔴 Fix Now |102| D2 | Outdated dependencies | `go list -m -u all` | 🟡 Fix Soon |103| D3 | Unused dependencies | `go mod tidy -v` (reports removed) | 🟡 Fix Soon |104105**How to fix:**106107- D1: `go get <module>@latest` for vulnerable deps, then `go mod tidy`.108- D2: `go get -u ./...` for all, or `go get <module>@latest` selectively.109- D3: `go mod tidy` removes unused; commit `go.mod` and `go.sum`.110111---112113### Step 2: Git Hygiene114115| # | Check | Command | Severity |116|---|-------|---------|----------|117| G1 | Stale local branches (merged) | `git branch --merged main \| grep -v '^\*\|main\|develop'` | 🟡 Fix Soon |118| G2 | Stale remote branches (merged) | `git branch -r --merged origin/main \| grep -v 'HEAD\|main\|develop'` | 🟡 Fix Soon |119| G3 | Large files in repo | See below | 🟡 Fix Soon (🔴 if >10MB) |120| G4 | `.gitignore` completeness | See below | 🟡 Fix Soon |121| G5 | Untracked files that should be ignored | `git status --porcelain \| grep '^??'` — look for build artifacts, IDE files, env files | ℹ️ Info |122| G6 | Uncommitted changes | `git status --porcelain` | ℹ️ Info |123124**G3 — Large files check:**125126```bash127# Top 10 largest tracked files128git ls-files -z | xargs -0 -I{} git log --diff-filter=A --format='%H' -1 -- '{}' | head -20129# Simpler: just check current tree130git ls-files -z | xargs -0 du -sh 2>/dev/null | sort -rh | head -10131```132133**G4 — .gitignore completeness:**134135Must include (per stack):136137- **Universal**: `.env`, `.env.*`, `*.local`, `.DS_Store`, `Thumbs.db`, `*.swp`, `.idea/`, `.vscode/` (or be deliberate about tracking it)138- **Node**: `node_modules/`, `dist/`, `build/`, `coverage/`, `.turbo/`, `.next/`139- **Python**: `__pycache__/`, `*.pyc`, `.venv/`, `venv/`, `.mypy_cache/`, `.pytest_cache/`, `*.egg-info/`140- **Go**: binary name (check `go build -o`), `vendor/` (if not vendoring)141142**How to fix:**143144- G1: `git branch -d <branch>` for each merged local branch.145- G2: `git push origin --delete <branch>` for each merged remote branch. Be careful — confirm with team.146- G3: For files that shouldn't be tracked: add to `.gitignore`, `git rm --cached <file>`. For files already in history: `git filter-repo` or BFG Repo-Cleaner (destructive — confirm first).147- G4: Add missing patterns to `.gitignore`. Use a generator like [gitignore.io](https://gitignore.io) as a starting point.148- G5: Either add to `.gitignore` or `git add` if they should be tracked.149150---151152### Step 3: CI/CD Health153154Skip if no CI configuration found.155156| # | Check | Command | Severity |157|---|-------|---------|----------|158| C1 | Workflow files exist | `ls .github/workflows/*.yml 2>/dev/null` | ℹ️ Info |159| C2 | Actions pinned by SHA | `grep -rE 'uses: [^@]+@v[0-9]' .github/workflows/` — should return nothing | 🟡 Fix Soon |160| C3 | Least-privilege permissions | Scan for `permissions:` blocks; flag `write-all` or missing job-level perms | 🟡 Fix Soon |161| C4 | No secret leaks in workflows | Check for `echo ${{ secrets.* }}`, secret in `$GITHUB_OUTPUT`/`$GITHUB_ENV` | 🔴 Fix Now |162| C5 | Deprecated actions | Check for known deprecated: `actions/create-release@v1`, `set-output` commands, `::set-env` | 🟡 Fix Soon |163| C6 | Node/Python version matches project | Compare workflow matrix with `engines`, `.nvmrc`, `pyproject.toml [requires-python]` | 🟡 Fix Soon |164165**How to fix:**166167- C2: Replace `uses: actions/checkout@v4` with `uses: actions/checkout@<full-sha>`. Find SHA: `gh api repos/actions/checkout/git/ref/tags/v4 --jq .object.sha` or check the releases page.168- C3: Add explicit `permissions:` at job level. Start with `contents: read` and add only what's needed.169- C4: Remove secret interpolation. Use `environment:` blocks or write to files with masking.170- C5: Replace deprecated actions with current equivalents. `set-output` → `$GITHUB_OUTPUT` file.171- C6: Align versions. Use `.nvmrc` or `engines` as the source of truth.172173---174175### Step 4: Code Quality Drift176177| # | Check | Command | Severity |178|---|-------|---------|----------|179| Q1 | TODO/FIXME/HACK count | `git grep -ciE '(TODO\|FIXME\|HACK)' -- '*.ts' '*.js' '*.py' '*.go' ':!node_modules' ':!vendor' ':!.venv'` | ℹ️ Info (🟡 if >20) |180| Q2 | `console.log` in src (JS/TS) | `git grep -c 'console\.log' -- 'src/**/*.ts' 'src/**/*.js' ':!*.test.*' ':!*.spec.*'` | 🟡 Fix Soon |181| Q3 | Disabled/skipped tests | `git grep -cE '(it\.skip\|test\.skip\|describe\.skip\|xit\|xdescribe\|@pytest\.mark\.skip\|t\.Skip)' -- '*.test.*' '*.spec.*' '*_test.*' '*_test.go'` | 🟡 Fix Soon |182| Q4 | Lint passes | `npm run lint` / `ruff check .` / `golangci-lint run` | 🟡 Fix Soon |183| Q5 | Tests pass | `npm test` / `pytest` / `go test ./...` | 🔴 Fix Now |184| Q6 | Build succeeds | `npm run build` / `uv build` / `go build ./...` | 🔴 Fix Now |185| Q7 | Type errors (TS) | `npx tsc --noEmit` | 🟡 Fix Soon |186| Q8 | Dead exports (TS) | `npx ts-prune 2>/dev/null \| grep -v '(used in module)'` | ℹ️ Info |187188**How to fix:**189190- Q1: Triage each TODO — either do it, create an issue/task for it, or remove it if obsolete.191- Q2: Replace with a proper logger, or remove debug logging. `grep -rn 'console.log' src/` to find them.192- Q3: Either fix the underlying issue and un-skip, or delete the test if the feature was removed.193- Q4–Q7: Fix the errors. Run the tool, address each issue.194- Q8: Remove unused exports, or add `// ts-prune-ignore-next` if they're part of the public API.195196---197198### Step 5: Documentation Freshness199200| # | Check | Command | Severity |201|---|-------|---------|----------|202| F1 | README.md exists | File check | 🔴 Fix Now |203| F2 | README freshness vs. source | Compare `git log -1 --format=%cr -- README.md` vs `git log -1 --format=%cr -- src/` | 🟡 if src is >30 days newer |204| F3 | CHANGELOG exists | File check | 🟡 Fix Soon (for published packages) |205| F4 | Broken internal links | See below | 🟡 Fix Soon |206| F5 | LICENSE file present | File check | 🔴 Fix Now |207| F6 | LICENSE matches package metadata | Compare LICENSE text with `package.json` `license` / `pyproject.toml` `license` | 🟡 Fix Soon |208| F7 | AGENTS.md references valid paths | If `.pi/AGENTS.md` exists, check that referenced files/dirs exist | 🟡 Fix Soon |209210**F4 — Broken link check:**211212```bash213# Find markdown links and verify targets exist214grep -roE '\[([^]]+)\]\(([^)]+)\)' *.md docs/**/*.md 2>/dev/null | \215 grep -v 'http' | \216 while IFS= read -r line; do217 # Extract path from markdown link218 path=$(echo "$line" | sed 's/.*](\([^)]*\)).*/\1/' | sed 's/#.*//')219 if [ -n "$path" ] && [ ! -e "$path" ]; then220 echo "BROKEN: $line"221 fi222 done223```224225**How to fix:**226227- F1: Write a README with: what it does, how to install, how to use, prerequisites, license.228- F2: Review README against current code — update examples, API docs, feature lists.229- F3: Add a CHANGELOG.md. Consider `@changesets/cli` for automated generation (see `pre-release` skill).230- F4: Update or remove broken links.231- F5: Add a LICENSE file. Use [choosealicense.com](https://choosealicense.com) if unsure.232- F6: Make LICENSE file and metadata agree.233- F7: Update AGENTS.md to reflect current project structure.234235---236237### Step 6: Configuration Consistency238239| # | Check | How | Severity |240|---|-------|-----|----------|241| X1 | EditorConfig present | `.editorconfig` exists | ℹ️ Info |242| X2 | Strict mode (TS) | `tsconfig.json` → `"strict": true` | 🟡 Fix Soon |243| X3 | Formatter configured | `.prettierrc` / `ruff.toml` / `gofmt` (built-in) | 🟡 Fix Soon |244| X4 | Linter configured | `.eslintrc*` or `eslint.config.*` / `ruff.toml` / `golangci-lint` config | 🟡 Fix Soon |245| X5 | Engine constraints match CI | `package.json` `engines` vs CI matrix; `pyproject.toml` `requires-python` vs CI | 🟡 Fix Soon |246| X6 | `.nvmrc` / `.python-version` matches | Compare with `engines` / `requires-python` / CI config | ℹ️ Info |247248**How to fix:**249250- X1: Add `.editorconfig`. Minimal: `root = true`, `[*]` block with `indent_style`, `indent_size`, `end_of_line`, `insert_final_newline`.251- X2: Set `"strict": true` in `tsconfig.json`. Fix resulting type errors (usually worth it).252- X3–X4: Add config files. Use the project's existing style as a baseline.253- X5–X6: Pick one source of truth (recommend `engines` / `requires-python`) and align everything else.254255---256257### Step 7: Security Posture258259Lightweight security checks for ongoing hygiene. For the full pre-release security audit260(gitleaks, trufflehog, workflow audit), use the `pre-release` skill.261262| # | Check | Command | Severity |263|---|-------|---------|----------|264| S1 | No tracked `.env` or `.local` files | `git ls-files '*.env' '*.env.*' '*.local' '*.local.*' '.env' '.env.local'` | 🔴 Fix Now |265| S2 | `.env.example` exists (if `.env` in `.gitignore`) | File check | 🟡 Fix Soon |266| S3 | No hardcoded secrets in source | `git grep -iE '(api[_-]?key\|secret\|password\|token)\s*[:=]\s*["\x27][^"\x27]{8,}' -- ':!*.lock' ':!node_modules' ':!*.example' ':!*.sample'` | 🔴 Fix Now |267| S4 | Secrets scanning config present | `.gitleaks.toml` or pre-commit hooks | ℹ️ Info |268| S5 | No broad file permissions | Check for `chmod 777` or `0777` in scripts | 🔴 Fix Now |269270**How to fix:**271272- S1: `git rm --cached <file>`, add to `.gitignore`, commit. If the file contained real secrets, rotate them immediately — they're in git history.273- S2: Create `.env.example` with placeholder values (`<REPLACE_ME>`) for every var in `.env`.274- S3: Move secrets to env vars or a secrets manager. Replace in code with `process.env.VAR` / `os.environ["VAR"]`.275- S4: Add `.gitleaks.toml` (even a minimal one enables CI scanning). Or add `gitleaks` to pre-commit hooks.276- S5: Use least-privilege permissions (`644` for files, `755` for executables).277278---279280### Step 8: Project Metadata281282| # | Check | How | Severity |283|---|-------|-----|----------|284| M1 | Required package fields | `name`, `version`, `description`, `license` in `package.json` / `pyproject.toml` | 🟡 Fix Soon |285| M2 | Repository URL set | `repository` field in package metadata | 🟡 Fix Soon |286| M3 | Keywords present | `keywords` array | ℹ️ Info |287| M4 | `FUNDING.yml` (public repos) | `.github/FUNDING.yml` exists | ℹ️ Info |288| M5 | Pi package compliance | If ships skills/extensions: `pi-package` keyword, `pi` manifest, `files` includes skill dirs | 🟡 Fix Soon (if applicable) |289290**How to fix:**291292- M1–M3: Add the missing fields to `package.json` or `pyproject.toml`.293- M4: Create `.github/FUNDING.yml` with `github: <username>`.294- M5: See [pi package docs](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent#pi-packages) for required fields.295296---297298## Baseline Tracking299300Save a baseline after each run to detect drift over time. Store at `.pi/hygiene-baseline.json`:301302```json303{304 "timestamp": "2026-02-14T23:00:00Z",305 "stack": ["node"],306 "scores": {307 "dependencies": { "status": "healthy", "vulns": 0, "outdated": 3, "unused": 0 },308 "git": { "status": "healthy", "stale_branches": 0, "large_files": 0 },309 "ci": { "status": "warning", "unpinned_actions": 2, "permission_issues": 0 },310 "quality": { "status": "healthy", "todos": 5, "skipped_tests": 0, "lint_clean": true },311 "docs": { "status": "warning", "readme_stale_days": 45, "broken_links": 1 },312 "config": { "status": "healthy", "strict_ts": true, "formatter": true, "linter": true },313 "security": { "status": "healthy", "tracked_env": 0, "hardcoded_secrets": 0 },314 "metadata": { "status": "healthy", "complete": true }315 },316 "overall": "7/10"317}318```319320On subsequent runs, compare with baseline and flag regressions:321322```text323📉 Dependencies: 0 → 3 vulnerabilities (regression since last check)324📈 Quality: 15 → 5 TODOs (improvement!)325→ CI: unchanged — 2 unpinned actions remain326```327328When the user approves the report, offer to update the baseline.329330---331332## Report Format333334Present the final report as a health scorecard:335336```markdown337# Repo Health: <project-name>338## Score: 7/10 — GOOD339## Stack: Node.js + TypeScript340## Last check: 2026-01-15 (30 days ago) | Baseline: 6/10 📈341342### 🔴 Fix Now (2)343| # | Category | Issue | Fix |344|---|----------|-------|-----|345| S1 | Security | `.env.local` tracked in git | `git rm --cached .env.local` |346| D1 | Deps | 2 high-severity npm audit findings | `npm audit fix` |347348### 🟡 Fix Soon (4)349| # | Category | Issue | Fix |350|---|----------|-------|-----|351| D2 | Deps | 8 outdated packages (2 major) | `npm outdated` → upgrade |352| C2 | CI | 3 actions not pinned by SHA | Pin to commit SHA |353| F2 | Docs | README 45 days behind source | Review and update |354| Q3 | Quality | 2 skipped tests | Fix or remove |355356### 🟢 Healthy (12)357- ✅ Dependencies: no unused, no phantom, lockfile fresh358- ✅ Git: clean tree, no stale branches, no large files359- ✅ Code: lint clean, build passes, tests pass, strict TS360- ✅ Config: EditorConfig, Prettier, ESLint all configured361- ✅ Security: no tracked secrets, .env.example present362- ✅ Metadata: all fields present, license matches363364### 📊 Trends (vs. baseline 2026-01-15)365| Category | Then | Now | Trend |366|----------|------|-----|-------|367| Vulnerabilities | 0 | 2 | 📉 |368| Outdated deps | 5 | 8 | 📉 |369| TODOs | 15 | 8 | 📈 |370| Skipped tests | 0 | 2 | 📉 |371372### Recommendations3731. **Immediate**: Fix the 2 security/vulnerability items above3742. **This week**: Pin CI actions and update stale README3753. **Ongoing**: Address skipped tests and outdated deps in next sprint376377Use your project's task tracking to schedule these items.378```379380---381382## Scoring383384Calculate the score from check results:385386| Result | Points deducted |387|--------|----------------|388| Each 🔴 Fix Now | −1.5 |389| Each 🟡 Fix Soon | −0.5 |390| ℹ️ Info | 0 |391392Start at 10, apply deductions, floor at 0. Round to nearest integer.393394| Score | Label |395|-------|-------|396| 9–10 | 🟢 EXCELLENT |397| 7–8 | 🟢 GOOD |398| 5–6 | 🟡 FAIR |399| 3–4 | 🟠 NEEDS WORK |400| 0–2 | 🔴 POOR |401402---403404## Auto-Fix Offers405406After presenting the report, offer to fix issues that are safe and mechanical.407**Always present what will be done and get confirmation before executing.**408409### Safe to offer (low risk, reversible)410411- Delete merged local branches (`git branch -d`)412- Run `npm audit fix` (compatible fixes only, not `--force`)413- Run `npm dedupe` / `go mod tidy`414- Add missing `.gitignore` patterns415- Add `.editorconfig` from template416- Remove `console.log` from source files417- Create `.env.example` from `.env` (with values replaced by `<REPLACE_ME>`)418- Add missing `package.json` fields (description, repository, keywords)419- Create `.github/FUNDING.yml`420421### Offer with warning (confirm carefully)422423- Delete merged remote branches (`git push origin --delete`)424- Run `npm audit fix --force` (may have breaking changes)425- Major dependency upgrades426- Enable TypeScript strict mode (may produce many errors)427- Update CI action pinning (must verify correct SHAs)428429### Never auto-fix (explain, let user decide)430431- Removing tracked `.env` files (may need secret rotation)432- Rewriting git history (BFG / filter-repo)433- Changing license files434- Modifying CI permissions model435- Removing hardcoded secrets (need to determine replacement strategy)436437---438439## Tips440441- **Run early, run often.** A monthly cadence catches drift before it compounds.442- **Don't try to fix everything at once.** Focus on 🔴 items first, batch 🟡 items into a maintenance sprint.443- **Baseline tracking is your friend.** Even if the score isn't perfect, trending upward means you're winning.444- **Pair with pre-release.** Run `repo-hygiene` for ongoing health, `pre-release` when you're ready to ship. They complement each other — hygiene keeps the baseline high so pre-release has fewer surprises.445- **New repos start clean.** Run this right after `git init` to establish a perfect baseline. It's easier to maintain 10/10 than to recover from 4/10.