debt-covenant-check
Skill8 starsChanged 4 months agoMITView on GitHub
Computes covenant ratios from the trial balance using the credit agreement's own component mappings and formulas, tracks headroom over time against prior compliance certificates, and flags approaching breaches — but only after confirming the trial balance itself balances. Use this whenever the user mentions debt covenants, covenant compliance, covenant headroom, leverage ratio, fixed charge coverage ratio, compliance certificate, loan covenant testing, or "are we in compliance with our credit agreement." Trigger on "check our covenants," "compute the leverage ratio," "are we close to breaching a covenant," "build the compliance certificate," or when a trial balance and covenant definitions are supplied together. Pairs with trial-balance-integrity, whose balance check this skill reuses before computing anything — if the TB doesn't balance yet, run that skill first.
- Installs packages
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- accrual-proposalsSkill
- ar-aging-tie-outSkill
- arr-waterfallSkill
- audit-samplingSkill
- audit-workpaperSkill
- balance-sheet-recon-packSkill
- bank-rec-reviewSkill
- bank-rec-to-glSkill
- bank-statement-to-excelSkill
- board-package-builderSkill
- budget-vs-actualSkill
- cash-applicationSkill
- cash-flow-tieoutSkill
- commission-recalcSkill
- consolidation-rollupSkill
- cutoff-and-unrecorded-liabilitiesSkill
- deferred-revenue-waterfallSkill
- depreciation-tie-outSkill
- dunning-draftsSkill
- duplicate-payment-scanSkill
- expense-policy-testingSkill
- filing-diffSkill
- flux-narrativeSkill
- fx-revaluationSkill
- intercompany-reconSkill
- invoice-codingSkill
- journal-entry-anomaly-scanSkill
- k1-extract-summarizeSkill
- lease-schedule-tie-outSkill
- month-end-close-checklistSkill
- payroll-tax-reconciliationSkill
- pbc-assemblerSkill
- prepaid-amortizationSkill
- receipts-to-expenseSkill
- return-yoy-varianceSkill
- revenue-trace-to-sourceSkill
- sales-tax-reconciliationSkill
- tax-return-reviewSkill
- thirteen-week-cash-forecastSkill
- three-way-matchSkill
- trial-balance-integritySkill
- vendor-statement-reconSkill
The file
Files
Debt Covenant Check
This is a quarterly ritual with real career risk attached if it's wrong, so it starts from the
same discipline as trial-balance-integrity: nothing is computed on a trial balance that doesn't
balance. Every covenant's formula, threshold, and account mapping comes from the client's actual
credit agreement — none of it is assumed or defaulted by the script.
The gate
The script refuses to compute anything, or refuses a specific covenant, when:
- The trial balance doesn't balance. Debits must equal credits before any covenant is
touched. If it doesn't, the whole run is blocked — run
trial-balance-integrityfirst. - A component's mapped account doesn't exist in the TB. That covenant becomes an exception, never computed with the missing account treated as zero.
- A covenant has no threshold or comparison operator supplied. The script refuses that covenant by name rather than assuming a "typical" leverage or coverage threshold.
- A formula can't be evaluated from the components actually supplied — divide-by-zero, an unrecognized component label, or unsupported syntax are all reported, never guessed around.
Early-warning headroom flags are opt-in: supply --warning-band-pct or the Approaching Breach tab
stays intentionally empty rather than silently applying an assumed band.
Inputs
- Trial balance —
account, debit, credit. - Covenant components —
covenant_name, component_label, account, operator(addorsubtract). This is how the client's own credit agreement defines what rolls into, say, "EBITDA" or "Fixed Charges" for that specific facility — addbacks and exclusions vary by agreement and are never assumed. - Covenant definitions —
covenant_name, formula_description, formula, threshold, comparison.formulais written using the component labels exactly as they appear in the components file (e.g.Total Debt / EBITDA).comparisonis>=,<=,>, or<. - Prior compliance certificates (optional) —
covenant_name, period, actual_value, for the headroom trend. --warning-band-pct(optional) — the percentage-of-threshold band that counts as "approaching" a breach. No default; omitting it means no early-warning test runs.
Step 1 — Get blank templates
python3 scripts/debt_covenant_check.py --template components --out components_template.csv
python3 scripts/debt_covenant_check.py --template definitions --out definitions_template.csvStep 2 — Run the check
python3 scripts/debt_covenant_check.py --tb trial_balance.csv \
--components covenant_components.csv --definitions covenant_definitions.csv \
--certificates prior_certificates.csv --warning-band-pct 15 \
--client "Northwind Systems Inc" --period "FY2026 Q1" \
--out "Northwind - Covenant Compliance.xlsx"A covenant failing its test (e.g., leverage above the cap) is a real finding, not a gate failure — the workbook still writes and reports the failure clearly. The gate is about whether the computation itself is trustworthy, not whether the client happens to be in compliance.
Deliver
Workbook tabs:
- Covenant Compliance — each covenant's computed value, threshold, comparison, pass/fail, headroom, whether it's in the approaching-breach band, and the prior-period trend beneath it.
- Component Trace — every account feeding every covenant, with its TB value and how it rolled into the component (add/subtract), so the computation can be audited line by line.
- Exceptions — covenants that couldn't be computed and why (missing account, missing threshold, unevaluable formula).
- Approaching Breach — only populated when
--warning-band-pctis supplied; otherwise it states plainly that no early-warning test was run, rather than appearing as a clean empty tab.
Then, in chat: whether the TB balanced, the pass/fail count, and any covenant currently failing or approaching its band — those are the only numbers that matter to the reader in the first sentence.
What to escalate
- Any covenant that fails. Report the computed value, the threshold, and the shortfall — do not characterize materiality or likely lender response.
- A covenant approaching its warning band for the first time, or trending toward it across the certificate history.
- A component mapping that looks inconsistent with the credit agreement's actual definitions discovered while building the components file — that's a conversation with whoever negotiated the facility, not a script decision.
- A trial balance that doesn't balance. This blocks the entire check and needs to be resolved before covenant compliance can be assessed at all.
Security posture
Fully local: standard library plus openpyxl. No network calls, no uploads, no telemetry. Trial
balance and credit agreement terms never leave the machine.
Dependencies
pip install openpyxlBuilt by Adopt AI — free to use and modify.
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.

