simplify-and-harden
Skill14 starsChanged 7 months agoMITView on GitHub
Post-completion self-review for coding agents that runs simplify, harden, and micro-documentation passes on non-trivial code changes. Use when: a coding task just completed, the diff touches executable source files with 10+ changed lines or high-impact logic (auth, validation, queries, file paths, network, concurrency). Feeds recurring findings into self-improving-agent via .learnings/LEARNINGS.md.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- pskoett/pskoett-ai-skillstheir own version, first seen Apr 13, 2026
- thoitiettxl-cyber/Claw-IItheir own version, first seen Apr 3, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- pskoett/pskoett-ai-skills★ 327same name
- thoitiettxl-cyber/Claw-II★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository41 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- llms.txtllms.txt
- brainstormingSkill
- drift-adr-workflowSkill
- drift-agent-prompt-authoringSkill
- drift-commit-pushSkill
- drift-dependency-updateSkill
- drift-docs-gap-fixSkill
- drift-evidence-artifact-authoringSkill
- drift-finding-message-authoringSkill
- drift-ground-truth-fixture-developmentSkill
- drift-mcp-repo-ops-usageSkill
- drift-pr-review-loopSkill
- drift-pr-reviewSkill
- drift-releaseSkill
- drift-risk-audit-artifact-updatesSkill
- drift-security-triageSkill
- drift-session-handover-authoringSkill
- drift-signal-development-full-lifecycleSkill
- fix-failing-actionsSkill
- grill-meSkill
- guard-src-drift-apiSkill
- guard-src-drift-commandsSkill
- guard-src-drift-ingestionSkill
- guard-src-drift-outputSkill
- guard-src-drift-signalsSkill
- guard-src-driftSkill
- improve-codebase-architectureSkill
- prd-to-issuesSkill
- self-improving-agentSkill
- skill-creatorSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- tddSkill
- test-driven-developmentSkill
- verification-before-completionSkill
- workspace-automation-orchestratorSkill
- write-a-prdSkill
- writing-plansSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Does NOT activate: when:
- Distinctive: line 32
Do NOT refactor adjacent code that was not modified
- Distinctive: line 33
Do NOT introduce new dependencies or architectural changes
- Very specific: line 39
If either limit is hit, stop and output what you have with a budget_exceeded flag
- Distinctive: line 47
Fresh-eyes start (mandatory): Before any edits, re-read all code added or modified with fresh eyes.
- Distinctive: line 76
Wait for explicit human approval before applying.
- Distinctive: line 82
Ask: *"If someone malicious saw this code, what would they try?"*
- Very specific: line 114
After each run, normalize recurring findings into pattern_keys and hand off to self-improving-agent:
- Very specific: line 130
Promote to
.learnings/LEARNINGS.md: when a pattern crosses the recurrence threshold: - Distinctive: line 174
After completing the task, run the Simplify & Harden review:
- Distinctive: line 178
Harden: Check for input validation gaps, injection vectors, auth issues, exposed secrets, and error handling problems.
- Distinctive: line 179
Document: Add up to 5 comments on non-obvious decisions.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Agent Skill: Simplify & Harden
Post-completion self-review: clean, harden, and document your work before moving on.
Source: https://clawhub.ai/pskoett/simplify-and-harden (v1.0.1, MIT-0, VirusTotal: Benign, OpenClaw: Benign HIGH CONFIDENCE)
Trigger Conditions
Activate automatically when ALL of the following are true:
- The agent has completed its primary coding task
- The diff contains a non-trivial code change:
- Touches at least one executable source file (
*.py,*.ts,*.js,*.go,*.rs, etc.) - AND includes either ≥10 changed non-comment/non-whitespace lines OR at least one high-impact logic change (auth/authz, input validation, data access, external commands, file paths, network requests, concurrency)
- Touches at least one executable source file (
- The skill has not already run on this task (no re-entry loops)
Does NOT activate when:
- The change is docs-only, config-only, comments-only, formatting-only, generated artifacts only, or tests-only
- The agent failed or was interrupted
- User explicitly skips via
--no-review
Scope Constraints
Hard rule: Only touch code modified in this task.
- Do NOT refactor adjacent code that was not modified
- Do NOT introduce new dependencies or architectural changes
- Flag out-of-scope concerns in the summary output rather than acting on them
Budget limits:
- Maximum additional changes: 20% of the original diff size (lines changed)
- Maximum execution time: 60 seconds
- If either limit is hit, stop and output what you have with a
budget_exceededflag
Pass 1: Simplify
Objective: Reduce unnecessary complexity introduced during implementation.
Default posture: Simplify, don't restructure. Bias heavily toward cosmetic fixes. Refactoring is the exception.
Fresh-eyes start (mandatory): Before any edits, re-read all code added or modified with fresh eyes. Actively look for obvious bugs, confusing logic, brittle assumptions, and naming issues.
Review Checklist
- Dead code — debug logs, commented-out attempts, unused imports, temp variables
- Naming clarity — function/variable names that made sense mid-implementation but read poorly after
- Control flow — nested conditionals that can be flattened, deep nesting replaceable by early returns
- API surface — exposed more than necessary? Can public methods become private?
- Over-abstraction — classes or wrappers not justified by current scope
- Consolidation — logic spread across functions/files when it could live in one place
Simplify Actions
- Cosmetic fix (dead code, unused imports, naming, control flow, visibility reduction) → applied automatically if within budget
- Refactor (consolidation, restructuring, abstraction changes) → proposed ONLY when genuinely necessary
Refactor Stop Hook (mandatory): Any refactor triggers an interactive prompt:
[simplify-and-harden] Refactor proposal (N of M):
What: [description]
Why: [rationale]
Files affected: [list]
Estimated diff: [+/- lines]
[approve] [reject] [show diff] [skip all refactors]Wait for explicit human approval before applying. Do not batch refactor proposals.
Pass 2: Harden
Objective: Close security and resilience gaps while the agent still understands the code's intent.
Ask: "If someone malicious saw this code, what would they try?"
Review Checklist
- Input validation — external inputs validated before use? Type coercion, bounds checks, unconstrained strings?
- Error handling — catch blocks specific? Errors logged without leaking sensitive data? Swallowed exceptions?
- Injection vectors — SQL injection, XSS, command injection, path traversal, template injection
- Auth/authz — new endpoints enforce auth? Permission checks present and correct? Privilege escalation risk?
- Secrets — hardcoded API keys, tokens, passwords? Connection strings parameterized? Credentials in logs?
- Data exposure — error output leaks internal state, stack traces, DB schemas, or PII?
- Dependency risk — new dependencies introduced? Well-maintained, properly versioned, no known CVEs?
- Race conditions — shared resources synchronized? TOCTOU vulnerabilities?
Harden Actions
- Patch (adding validation, escaping output, removing hardcoded secret) → applied automatically if within budget
- Security refactor (restructuring auth flow, replacing vulnerable pattern) → ALWAYS requires human approval
Same Refactor Stop Hook applies with added severity and attack vector context.
Pass 3: Document (Micro-pass)
Objective: Capture non-obvious decisions while the agent still remembers why it made them.
Rules:
- For logic requiring >5 seconds of "why does this exist?" thought: add a single-line comment
- For any workaround or hack: add a comment with context and a TODO with removal conditions
- For performance-sensitive choices: note why current approach was chosen over obvious alternative
- Maximum: 5 comments added per task
Self-Improvement Integration
After each run, normalize recurring findings into pattern_keys and hand off to self-improving-agent:
learning_loop:
target_skill: "self-improvement"
log_file: ".learnings/LEARNINGS.md"
candidates:
- pattern_key: "simplify.dead_code" # simplify.* or harden.*
pass: "simplify"
finding_type: "dead_code"
severity: "low"
source_file: "src/..."
source_line: 12
suggested_rule: "Remove dead code before finalizing a task."Promote to .learnings/LEARNINGS.md when a pattern crosses the recurrence threshold:
- ≥3 occurrences across ≥2 distinct tasks in a 30-day window
- Then consider promotion to
CLAUDE.md,AGENTS.md, or.github/copilot-instructions.md
Output Schema
simplify_and_harden:
version: "0.1.0"
task_id: "<original task ID>"
execution:
mode: "interactive"
human_present: true
scope:
files_reviewed: [...]
original_diff_lines: N
additional_changes_lines: N
budget_exceeded: false
simplify:
applied: [...]
flagged: [...]
cosmetic_applied: [...]
harden:
applied: [...]
flagged_critical: [...]
flagged_advisory: [...]
document:
comments_added: N
locations: [...]
learning_loop:
candidates: [...]
summary:
simplify_applied: N
harden_applied: N
harden_flagged_critical: N
comments_added: N
budget_utilization: "X%"
review_followup_required: true|falseSet review_followup_required: true when any unresolved finding remains (critical/advisory flags, skipped refactors) or budget_exceeded: true.
Prompt-based Integration (GitHub Copilot)
After completing the task, run the Simplify & Harden review:
- Review only the files you modified
- Simplify: Your default action is cleanup — remove dead code, unused imports, fix naming, tighten control flow, reduce unnecessary public surface. Apply these directly. Refactoring is NOT the default. Only propose a refactor when the code is genuinely wrong or the improvement is substantial. If you propose one, describe it and ask for approval before applying.
- Harden: Check for input validation gaps, injection vectors, auth issues, exposed secrets, and error handling problems. Apply simple patches directly. For security refactors that change structure, describe the issue with severity and ask for approval.
- Document: Add up to 5 comments on non-obvious decisions.
- Output a summary of what you changed, what you flagged, and what you left alone.
Core Invariants
- Scope lock — only files modified in the current task
- Budget cap — 20% max additional diff
- Simplify-first posture — cleanup is the default, refactoring is the exception
- Refactor stop hook — structural changes always require human approval
- Three passes — simplify, harden, document (in that order)
- Structured output — summary of applied, approved, rejected, and flagged items
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.

