- Home
- Skills
- Code Quality & Review
- Draft Diff Guard
Works with the AI Agents you already use
Draft Diff Guard
Enforce dry-runs and 4-point sanity checks to prevent destructive code edits and stubbed implementations.
$3
Draft Diff Guard
Example session with this skill installed
Refactor the calculateTotal function in src/finance.ts to include tax, but keep all existing JSDoc comments and don't change the function signature.
- Read your context and instructions
- Compiled the draft diff guard
I have staged the requested changes for src/finance.ts. The implementation includes tax logic while maintaining the existing API contract and documentation. All pre-flight sanity checks have passed.
📋 Proposed Changes (Staged Dry-Run)
Files to modify:
src/finance.ts(+5 lines, -2 lines)
Summary of Changes:
- Updated
calculateTotalto include a 5% tax calculation. - Preserved existing JSDoc documentation and parameter names.
- Ensured the return type remains a number to satisfy downstream callers.
Four-Point Sanity Checklist:
- Preservation: All comments, docstrings, and license headers preserved.
- Scope Lock: Strictly restricted to requested files.
- Contract Guard: Public exports and interfaces preserved.
- No Placeholders: Complete implementation, zero TODO/pass stubs.
- Pre-Flight Gate: Syntax check passed cleanly.
Unified Diff Preview:
--- a/src/finance.ts
+++ b/src/finance.ts
@@ -1,10 +1,13 @@
/**
* Calculates the total price for a set of items.
* @param prices Array of item prices.
* @returns The sum of all prices.
*/
export function calculateTotal(prices: number[]): number {
- return prices.reduce((a, b) => a + b, 0);
+ const subtotal = prices.reduce((a, b) => a + b, 0);
+ const taxRate = 0.05;
+ const total = subtotal * (1 + taxRate);
+ return total;
}
Next steps
- Review the tax rate calculation logic.
- Confirm if a 5% fixed rate is acceptable or needs to be a parameter.
- Approve the changes to apply them to
src/finance.ts.
Approval Gate: Ready to apply changes to disk. Proceed? (yes / no / revise)
Connects securely to your tools. The creator never sees your data.
About this skill
Uncontrolled AI edits can lead to stripped comments, broken public APIs, and dangerous placeholder stubs in production code. draft-diff-guard enforces a strict dry-run protocol that prevents agents from writing directly to disk until changes are validated against rigorous quality gates.
What it does
- Staged Dry-Runs creates in-memory buffers and unified diffs to prevent premature or accidental file mutations.
- Comment Preservation ensures docstrings, JSDoc, license headers, and inline explanations remain intact during refactoring.
- Scope Locking restricts modifications to authorized files, blocking unrequested formatting or "drive-by" refactors.
- Contract Guarding protects public APIs and function signatures from breaking changes or unintentional renaming.
- Placeholder Detection rejects any code containing
TODO,pass, orNotImplementedErrorstubs.
How it works
- Stage Buffer: The agent generates a staged version of the proposed file change in memory without touching the disk.
- Execute Sanity Checks: The system runs the four-point checklist to verify preservation, scope, contracts, and completeness.
- Pre-Flight Verification: Automated syntax checks and the
diff_guard.pyscript validate the diff for technical correctness. - Interactive Approval: A structured summary and unified diff are presented for human review before final disk write.
Frameworks & tools
This skill includes standalone validation scripts in Python and Node.js. It integrates with AST parsers and language-specific syntax checkers like tsc --noEmit or node --check to ensure code integrity.
Why this beats prompting it yourself
Generic prompts often fail to catch subtle regressions like missing license headers or new TODO stubs during complex refactors. This skill provides a programmatic enforcement layer with a dedicated diff_guard script that acts as a hard gate, ensuring your agent follows high-stakes engineering standards every time.
Use cases
- Refactoring legacy modules where preserving original comments and docstrings is critical for maintenance.
- Preventing agents from polluting PRs with unrelated formatting changes in adjacent files.
- Ensuring API stability by flagging unintentional changes to exported function signatures.
- Catching incomplete implementations or stubs before they reach your CI pipeline.
Known limitations
Requires a local environment capable of running Python or Node.js scripts for the validation gates. Performance may vary depending on the size of the unified diff being analyzed.
Requires Python or Node.js environment to run the diff_guard validation scripts. Performance scales with diff size.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 10 days ago
Requires