code-hygiene-auditor
Skill0 starsChanged 55 days agoMITView on GitHub
Operational protocol for conducting comprehensive pre-commit quality, security, and repository hygiene audits. Use when: performing pre-commit verification, verifying zero compiler warnings (-warnings-as-errors), ensuring no untracked scratch files, test binaries, or .DS_Store files linger in the working tree, auditing .gitignore coverage, and verifying clean test suite passes before concluding tasks.
- Reads credentials
In this repository11 other files it gives its agents.
- templates/AGENTS.mdAGENTS.md
- appstore-privacy-auditorSkill
- ci-cd-automationSkill
- codebase-bootstrapSkill
- git-atomic-curatorSkill
- iphone-duo-migratorSkill
- swift-concurrency-doctorSkill
- swiftui-layout-debuggerSkill
- token-optimizerSkill
- xcode-ci-doctorSkill
- zero-secret-sanitizerSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
Immaculate Working Tree: No untracked temporary files, scratch artifacts, or orphaned build folders left behind.
- Distinctive: line 27
Green Test Suite: All unit and regression tests must pass deterministically before concluding work.
- Distinctive: line 51
Every production codebase managed by an AI agent must configure warnings-as-errors to prevent technical rot:
- Very specific: line 243
Ensure every repository maintains a robust root .gitignore covering platform and IDE noise:
- Distinctive: line 312
Before marking any task complete or submitting a pull request, run through this checklist:
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Hygiene Auditor (Pre-Commit Quality & Security Verification) 🧹🔍
The definitive operational manual for AI coding agents tasked with performing strict pre-flight quality, security, and cleanliness audits prior to committing code or concluding tasks.
1. Executive Summary & Core Philosophy
Clean code hygiene is the firewall that prevents technical debt, leaked credentials, broken builds, and messy git histories from entering production repositories.
- Failure Modes of AI Agents:
- Leaving unused debug print statements (
print(),console.log()), scratch files, or test binaries in working directories. - Overlooking compiler warnings that signify impending data races or deprecated API usage.
- Forgetting to run
git statusbefore finishing a task, accidentally committing.DS_Storeor.envfiles. - Disabling linters or silencing type checkers with
@ts-ignoreoras anyinstead of fixing the root cause.
- Leaving unused debug print statements (
- The Auditor's Mandate:
- Zero Secrets: Exhaustive regex scanning across all modified files before every commit.
- Zero Compiler Warnings: Builds must compile cleanly with zero warnings under modern strict compiler flags (
-warnings-as-errors). - Immaculate Working Tree: No untracked temporary files, scratch artifacts, or orphaned build folders left behind.
- Green Test Suite: All unit and regression tests must pass deterministically before concluding work.
2. The 5-Pillar Code Hygiene Framework
+-----------------------------------------------------------------------------------------+
| 5-PILLAR HYGIENE FRAMEWORK |
+---------------------+-------------------------------------------------------------------+
| Pillar | Verification Objective & Standard |
+---------------------+-------------------------------------------------------------------+
| 1. Security | 0 credentials, 0 private keys, 0 unencrypted secrets in git diff |
| 2. Compilation | 0 errors, 0 compiler warnings, strict type and concurrency checks |
| 3. Test Suite | 100% test pass rate with deterministic assertion coverage |
| 4. Working Tree | Clean git status; all build artifacts properly gitignored |
| 5. Git Commit | Atomic staging, Conventional Commits prefix, descriptive scope |
+---------------------+-------------------------------------------------------------------+3. Language-Specific Compiler Warning Enforcement
Every production codebase managed by an AI agent must configure warnings-as-errors to prevent technical rot:
3.1 Swift 6 & Apple Platforms
Enforce zero warnings and strict concurrency in Package.swift:
// swift-tools-version: 6.0
import PackageDescription
let package = Package(
name: "CoreEngine",
platforms: [.iOS(.v17), .macOS(.v14)],
products: [
.library(name: "CoreEngine", targets: ["CoreEngine"]),
],
targets: [
.target(
name: "CoreEngine",
swiftSettings: [
.unsafeFlags(["-warnings-as-errors"]),
.enableUpcomingFeature("StrictConcurrency"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("InternalImportsByDefault"),
]
),
.testTarget(
name: "CoreEngineTests",
dependencies: ["CoreEngine"],
swiftSettings: [
.unsafeFlags(["-warnings-as-errors"])
]
),
]
)CLI Build Command:
swift build -Xswiftc -warnings-as-errors3.2 TypeScript / Node.js
Strict type checking configuration in tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true
}
}CLI Typecheck Command:
pnpm tsc --noEmit3.3 Rust Systems
Configure Cargo to treat all compiler and clippy warnings as compilation errors:
# In CI and pre-commit checks:
RUSTFLAGS="-D warnings" cargo check --all-targets --all-features
cargo clippy --all-targets --all-features -- -D warnings3.4 Python Backend
Strict linting and type checking via ruff and mypy:
# pyproject.toml
[tool.ruff]
target-version = "py312"
line-length = 100
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
]
deny-warnings = true
[tool.mypy]
strict = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = trueCLI Audit Command:
uv run ruff check .
uv run mypy .3.5 Go Microservices
Configure golangci-lint with strict defaults:
golangci-lint run --enable-all -D gochecknoglobals,godox4. Production Pre-Commit Hygiene Audit Script
Include this automated pre-commit audit runner in scripts/audit-hygiene.sh to execute before every commit:
#!/usr/bin/env bash
# audit-hygiene.sh — Pre-flight quality and security validator
set -euo pipefail
echo "🔍 Starting Pre-Flight Code Hygiene Audit..."
FAILURES=0
# 1. Check for uncommitted merge conflict markers
echo -n " Checking for merge conflict markers... "
if git grep -E "^(<<<<<<<|=======|>>>>>>>)" -- ':!*.md' ':!*.resolved' 2>/dev/null; then
echo "❌ FAILED: Merge conflict markers found in tracked files!"
FAILURES=$((FAILURES + 1))
else
echo "✅ Clean"
fi
# 2. Check for leftover debug statements
echo -n " Checking for leftover debug statements... "
DEBUG_MATCHES=$(git diff --cached -S "console.log" -S "print(" -S "dbg!" -S "fmt.Println" -- ':!*test*' ':!*Test*' 2>/dev/null || true)
if [ -n "$DEBUG_MATCHES" ]; then
echo "⚠️ WARNING: Possible debug print statements staged in diff:"
echo "$DEBUG_MATCHES" | head -n 5
else
echo "✅ Clean"
fi
# 3. Check for lingering scratch files
echo -n " Checking for untracked scratch/temporary files... "
UNTRACKED=$(git status --porcelain | grep -E "^\?\?" | grep -E "\.(tmp|scratch|log|DS_Store|swp)$" || true)
if [ -n "$UNTRACKED" ]; then
echo "❌ FAILED: Lingering scratch files found in working tree:"
echo "$UNTRACKED"
FAILURES=$((FAILURES + 1))
else
echo "✅ Clean"
fi
# 4. Check for .env or private key files
echo -n " Checking for staged secrets or .env files... "
STAGED_SECRETS=$(git diff --cached --name-only | grep -E "\.(env|pem|key|p12|p8)$" || true)
if [ -n "$STAGED_SECRETS" ]; then
echo "🚨 CRITICAL: Staged credential files detected!"
echo "$STAGED_SECRETS"
FAILURES=$((FAILURES + 1))
else
echo "✅ Clean"
fi
# 5. Summary
if [ "$FAILURES" -gt 0 ]; then
echo "❌ Hygiene audit failed with $FAILURES issues. Resolve them before committing."
exit 1
else
echo "🎉 All hygiene checks passed cleanly. Ready for commit."
exit 0
fi5. Universal .gitignore Best Practices
Ensure every repository maintains a robust root .gitignore covering platform and IDE noise:
# macOS System Files
.DS_Store
.AppleDouble
.LSOverride
Icon?
._*
# Xcode & Apple Developer
DerivedData/
*.xcscmblueprint
*.xcuserstate
xcuserdata/
*.xcbkptlist
.build/
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# Node / TypeScript
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.next/
dist/
build/
.turbo/
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
.venv/
.mypy_cache/
.ruff_cache/
.pytest_cache/
# Rust / Cargo
/target/
**/*.rs.bk
# Go
bin/
/pkg/
# Environment & Secrets
.env
.env.*
!.env.example
*.pem
*.key
*.p12
*.p8
*.mobileprovision6. Pre-Flight Verification Checklist
Before marking any task complete or submitting a pull request, run through this checklist:
- Working Tree:
git statusshows zero unexpected untracked files or leftover scratch scripts. - Zero Warnings: Compiler succeeds cleanly with warnings treated as errors.
- Tests Green: Entire test suite passes without flaky or disabled tests.
- No Secret Leaks:
git diff --cachedcontains no API keys, private tokens, or credentials. - Atomic Commits: Changes are grouped logically with Conventional Commit messages (
feat:,fix:,refactor:,test:). - Documentation: Any new commands, flags, or configuration options are updated in
README.mdorAGENTS.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

