Use when documents must be submitted to an authority and pass first time — visa, rental, mortgage, benefits, insurance, grant, licensing — to check the folder for missing, expired, or mutually inconsistent documents with page-level citations. Offline, deterministic, no model calls. Not legal advice, not an eligibility decision, not OCR.
---
name: packet-audit
description: "Use when documents must be submitted to an authority and pass first time — visa, rental, mortgage, benefits, insurance, grant, licensing — to check the folder for missing, expired, or mutually inconsistent documents with page-level citations. Offline, deterministic, no model calls. Not legal advice, not an eligibility decision, not OCR."
metadata: {"version": "1.1.1", "license": "MIT-0", "offline": true, "entrypoints": ["scripts/packet_audit.py", "scripts/self_check.py"]}
---
# Packet Audit
A submission packet fails on the details nobody cross-checks: the address on the bank
statement is last year's, the passport expires two weeks before the decision date, the
name on the payslip has an `e` where the passport has an `a`. Packet Audit walks a folder
of documents, extracts the fields that must agree, and reports every disagreement,
missing document, and expired credential with the file and page it came from.
It produces evidence, not prose: a findings list, a document inventory with SHA-256 per
file, and a JSON manifest of the exact packet that was checked.
## When to use
- A set of documents is about to be submitted and acceptance matters: visa or residence
application, rental application, mortgage or refinance file, benefits claim, insurance
claim, grant or tender response, professional licensing.
- A previous submission was rejected and the user needs to know which document caused it.
- Someone is assembling a packet for another person (family member, client, employee)
and needs a second pair of eyes that cites sources.
- A records folder has accumulated duplicates, scans, and stale credentials and needs a
defensible inventory before it goes anywhere.
## When not to use
- Deciding whether someone qualifies. This skill checks documents against each other and
against a declared checklist; it never decides eligibility.
- Legal, tax, or immigration advice. It cites what the packet says, not what the law allows.
- Reading photographed or scanned pages. Images and image-only PDFs are reported as
unreadable; this skill does not perform OCR and will not guess at a value.
- Writing the application, the cover letter, or the appeal. Use a drafting skill for that,
then run this one over the result.
- Auditing a single document against itself (numbering, cross-references, terminology) —
that is an editorial check, not a packet check.
## Quickstart
```bash
npx --yes clawhub@0.23.3 install deepseekoracle/packet-audit@1.1.1
```
```bash
python3 scripts/packet_audit.py --list-profiles
python3 scripts/packet_audit.py --folder ./my-packet --profile rental-us --decision-date 2027-06-01
python3 scripts/packet_audit.py --folder ./my-packet --profile schengen-visa --decision-date 2027-06-01 --json
```
The audit writes three files into `--out` (default `<folder>/.packet-audit`):
`packet-report.md`, `packet-report.json`, `packet-manifest.json`.
Exit codes: `0` clean, `1` warnings only, `2` blocking findings, `3` bad input. A CI job or
an agent can gate on the exit code without parsing prose.
## Bundled profiles
| Profile | Packet | Blocking rules |
|---|---|---|
| `rental-us` | US rental application | photo ID present and valid 30 days past the decision date, proof of income, completed form, name/address/income agree |
| `schengen-visa` | Schengen short-stay visa | passport valid 90 days past the decision date, insurance cover live, accommodation, funds, itinerary, name/DOB agree |
| `insurance-claim-property` | Property insurance claim | policy schedule, claim form, invoice or proof of ownership, damage photographs, policy number and loss date agree |
Profiles are data, not code: a new packet type is a new JSON file, and the engine does not
change. See `references/authoring-a-profile.md`.
## Finding codes
| Code | Severity | Meaning |
|---|---|---|
| `PA-E01` | error | A required document type is absent from the packet |
| `PA-X01` | error | A document expires before the profile's validity window closes |
| `PA-C01` | error | A field disagrees across two documents |
| `PA-C02` | warning | A field differs only in spelling or wording |
| `PA-C03` | warning | The authoritative document is in the packet but does not show the field, so agreement is checked against a fallback |
| `PA-F01` | warning | A required field was not found in a document that should carry it |
| `PA-X02` | warning | An expiry date could not be parsed |
| `PA-R01` | warning | A file could not be read (image, scan, or no PDF text layer) |
| `PA-D01` | info | Two files are byte-identical |
| `PA-U01` | info | A file matched no document type and was not checked |
`references/finding-codes.md` carries the full detail, including what each finding looks
like in the report and how to act on it.
## Outputs
- `packet-report.md` — verdict, findings table, document inventory, extracted values, next actions.
- `packet-report.json` — the same content with a stable schema (`packet-audit/report/1`),
including the profile id and its SHA-256 so a result can be reproduced.
- `packet-manifest.json` — path, size, SHA-256, classified type, and readability per file.
## Permissions
- **Filesystem, read:** the folder passed to `--folder`, recursively.
- **Filesystem, write:** only `--out` (default `<folder>/.packet-audit`).
- **Network:** none. No upload, no telemetry, no model call, no package install at runtime.
- **Subprocess:** none.
- **Environment:** none required, and no third-party import is needed to read a PDF: the
bundled `scripts/pdftext.py` is standard library only. `pypdf` is used only as a fallback
when it is already importable; the skill never installs or fetches anything.
## Limits and non-claims
Text comes from `.txt`, `.md`, `.csv`, `.json`, `.docx` and `.pdf` with the standard library
(a sibling `<name>.pdf.txt` text dump is used when one exists). A PDF needs a text layer:
encrypted files and scans are reported with that reason, never guessed at. Classification and field extraction are
pattern-based heuristics, not comprehension: a document that hides a value inside prose or
inside a table image will come back as `PA-F01`, not as a wrong value. Confirm the
authority's own checklist before submitting — the bundled profiles are starting points, and
`references/limits.md` lists the rest of what this deliberately does not do.
## References
- `references/finding-codes.md` — every code, its severity, and the action it implies.
- `references/authoring-a-profile.md` — profile schema, worked example, validation rules.
- `references/limits.md` — what the audit cannot see, and why it says so instead of guessing.
## Self-check
```bash
python3 scripts/self_check.py
python3 -m unittest discover -s tests
```
The self-check runs one named rule per known release hazard (version agreement, profile
validity, no network imports, no absolute paths, pinned installs, compilation, CLI smoke,
no HTML comments, test presence, declared scope) and exits non-zero if any rule fails.
don't have the plugin yet? install it then click "run inline in claude" again.
extracted and formalized the original's implicit procedure into 10 explicit steps, made decision points airtight with branch conditions and edge cases (unreadable files, unparseable dates, missing authoritative source, bad input), documented filesystem and network constraints as inputs, and clarified output file locations and schema stability for CI use.
packet-audit walks a folder of documents (PDF, DOCX, TXT, MD, CSV, JSON) and checks them against each other and against a profile (visa, rental, mortgage, benefits, insurance, grant, licensing). it extracts fields that must agree across documents (name, address, income, dates), flags missing required documents, detects expired credentials relative to a decision date, and reports every disagreement with the exact file and page it came from. use this when you have one shot to get it right: a submission packet that will be reviewed by an authority and rejection means delay, cost, or loss. it produces structured findings (JSON + markdown), a manifest with file hashes, and an exit code suitable for CI gates. it does not decide eligibility, give legal advice, perform OCR, or guess at values it cannot read.
rental-us, schengen-visa, insurance-claim-property) or a custom profile JSON file. required. see references/authoring-a-profile.md for schema.<folder>/.packet-audit. optional.packet-report.json in addition to markdown. optional.scan and classify. recursively list all files in --folder. for each file, record path, size (bytes), and SHA-256 hash. attempt to read the file as text (.txt, .md, .csv, .json, .docx, .pdf). if a file is unreadable (encrypted PDF, image-only scan, binary), mark it PA-R01 (warning, unreadable) and skip field extraction. if a .pdf.txt sibling file exists, prefer that text dump over PDF extraction. output: file manifest with type classification and readability status.
extract fields by pattern. for each readable document, apply pattern-based heuristics (regex, field marker detection, table parsing from text) to find values like name, address, date of birth, income, policy number, expiry date, ID number. heuristics are profile-specific and defined in the profile JSON. if a required field is not found, record PA-F01 (warning, field not found). do not guess or fill. output: extracted fields keyed by document path and field name, with page number if available.
load profile. read the profile JSON (bundled or custom). extract the list of required document types, the set of fields that must agree across documents (e.g. "name must agree between passport and rental form"), the expiry rules (e.g. "passport must be valid 90 days after decision date"), and the blocking rules (which findings cause exit code 2 vs 1). output: in-memory profile object.
check document presence. compare the classified documents in the folder against the profile's required document types. for each required type not found, emit PA-E01 (error, missing document). output: list of missing document findings.
check expiry. for each document that carries an expiry date field (passport, insurance policy, ID), extract the date value. if the date cannot be parsed, emit PA-X02 (warning, expiry unparseable). if the date is before decision-date + profile.validity-window (e.g. passport must be valid 90 days after decision date), emit PA-X01 (error, expires before cutoff). output: list of expiry findings.
check field agreement. for each field in the profile's agreement rules (e.g. "name agrees between passport and payslip"), extract the field value from both documents. if the values differ exactly, emit PA-C01 (error, field disagrees). if the values differ only in spelling, punctuation, or wording (e.g. "Mary Jane" vs "M.J."), emit PA-C02 (warning, field differs in wording). if the authoritative document (e.g. passport) does not carry the field but a fallback does (e.g. form), emit PA-C03 (warning, agreement checked against fallback). output: list of agreement findings.
check for duplicates. compare SHA-256 hashes of all files in the manifest. if two files are byte-identical, emit PA-D01 (info, duplicate found). output: list of duplicate findings.
classify unmatched files. for each file that did not match any document type in the profile, emit PA-U01 (info, unclassified). output: list of unclassified file findings.
compile report. write three files to --out:
packet-report.md: human-readable markdown with verdict, findings table (sortable by code/severity), document inventory (file, size, hash, type, readability), extracted values per document, and next actions.packet-report.json: structured report with schema packet-audit/report/1, including all findings, inventory, extracted values, profile ID, and profile SHA-256 for reproducibility.packet-manifest.json: manifest of files (path, size, hash, type, readable).set exit code. scan all findings for blocking rules (profile-defined). if any finding is marked blocking (e.g. PA-E01 missing document is blocking), exit 2. else if any finding is PA-X01, PA-C01, or other error, exit 2. else if any warning is present, exit 1. else exit 0. output: process exit code.
if a document file is unreadable (encrypted, scanned image, no text layer): emit PA-R01 (warning, unreadable) and skip field extraction for that file. do not attempt OCR or image processing. do not emit errors for missing fields in unreadable documents.
if a required field is not found in a document that should carry it: emit PA-F01 (warning, field not found). do not leave the field blank or assume a default. do not check agreement if the authoritative source is unreadable.
if the authoritative document does not carry a required field, but a fallback document does: emit PA-C03 (warning, agreement checked against fallback) and proceed to compare the fallback value against other documents. example: passport does not show income, but payslip does, so income is checked against payslip and form.
if an expiry date cannot be parsed (malformed, ambiguous): emit PA-X02 (warning, expiry unparseable). do not assume a date or skip the check. flag it so the user can manually verify.
if a field value differs only in spelling, punctuation, or minor wording (e.g. "St." vs "Street", "John A." vs "John Albert"): emit PA-C02 (warning, spelling or wording difference) instead of PA-C01 (error, full disagreement). do not block submission on PA-C02 alone.
if two files are byte-identical (same SHA-256): emit PA-D01 (info, duplicate) for visibility. the duplicate does not cause a finding against the packet; it is informational.
if a file matches no document type in the profile: emit PA-U01 (info, unclassified). continue to process the file for field extraction if readable, in case it is a custom or unknown variant.
if the profile is not found (bundled or custom path): exit with code 3 and print error message. do not fall back to a default profile.
if --decision-date is not supplied or is malformed: exit with code 3 and print error message. this date is required for all expiry checks.
if --folder does not exist or is not readable: exit with code 3 and print error message.
if --out directory cannot be created or written to: exit with code 3 and print error message.
file locations: all reports are written to --out (default <folder>/.packet-audit). the directory is created if it does not exist.
packet-report.md: markdown format. contains verdict (pass/warnings/fail), findings table sorted by code, document inventory with size and hash, extracted values, and recommended next actions.packet-report.json: JSON object with schema version packet-audit/report/1. top-level keys: verdict (pass|warnings|fail), profile_id, profile_sha256, decision_date, findings (array of finding objects, each with code, severity, message, file, page, context), inventory (array of files with path, size_bytes, sha256, type, readable), extracted_values (object keyed by file path, nested by field name), timestamp_utc. findings array is stable across runs for the same input.packet-manifest.json: JSON object. top-level keys: files (array of file objects, each with path, size_bytes, sha256, type, readable), timestamp_utc, profile_id, decision_date. used for reproducibility and audit trail.data format stability: schema version is pinned in reports. if the report schema changes in future versions, the version key changes so consumers can detect it.
no other outputs: the skill does not upload files, send emails, or write to external systems. all output is local filesystem.
exit code 0 (clean): all required documents are present, no fields disagree, no credentials expire, no unreadable files. the packet is ready to submit.
exit code 1 (warnings only): all required documents are present and no errors block submission, but warnings are present (spelling differences, unreadable files, unparseable dates, unclassified files, duplicates). review the warnings in packet-report.md and decide whether to proceed or investigate further.
exit code 2 (blocking findings): one or more errors are present (missing document, field disagreement, credential expires, exact field mismatch). the packet should not be submitted until these are resolved. see packet-report.md for the list and next actions.
exit code 3 (bad input): the command itself is malformed (missing --folder, --profile, --decision-date, or unreadable paths). fix the command and retry.
human verification: open packet-report.md to read the verdict and findings in prose. each finding cites the file and page it came from. use the finding code (e.g. PA-C01) to look up the action in references/finding-codes.md. open packet-report.json to integrate results into a CI pipeline or audit log. open packet-manifest.json to verify the exact set of files that were checked (useful for reproducibility and disputes).
no blocking findings + exit 0 or 1: the packet is audit-ready. if warnings remain, address them before submission or document the reason for each warning in a cover letter. if exit 0, submit with confidence.