AuditCore Multi-Agent Collaborative Audit and Workpaper Generation Skill
I. Architecture Overview
The AuditCore Skill adopts a "Host-Brain + Deterministic-Core" architecture:
- No External API Key Multi-Agent Blind Review Committee: Directly reuses the host agent's (Claude Code, Antigravity, Codex, OpenClaw, etc.) sub-agent dispatch capability to spawn four contextually isolated audit roles (
junior-auditor,challenger-auditor,fact-checker,senior-partner). - Deterministic Patent Algorithm Core (
scripts/audit_cli.py) : Uses a stateful CLI engine to enforce PII encryption/masking and SHA-256 hash chain audit logs, three-tier materiality filtering, six-dimensional deterministic rule penetration (Benford's Law, Z-Score, rounding anomalies, weekend transactions, same-day split transactions, negative reversal/duplicate vouchers) , PyTorch-free three-way hybrid regulatory retrieval $H(q, c_i)$ , four-layer evidence topology causal graphs and bipartite graph loss verification, DAG state machine minimum-cut local rollback, and CSA-1131 four-element Word (.docx) / Markdown (.md) workpaper auto-generation with PII reverse restoration.
II. Three Core Iron Rules (Violation of any rule renders the audit invalid)
IRON RULE 1: Zero-Leakage Privacy Gate
- Strictly prohibited from directly reading the original account set: Before or after executing
scripts/audit_cli.py init, it is absolutely forbidden to usepandas,python,cat,head, or any file reading tool to directly view the user's original.xlsx/.csvfile contents! - Strictly prohibited from touching the encrypted safe: The
.auditcore_workspace/cases/<CASE_ID>/.vault_do_not_read.jsonfile generated byinitis encrypted with XOR-SHA256-HMAC to store real entity and account mappings. The host and any sub-agents are strictly forbidden from reading or decrypting this file. - Full workflow masked reasoning: All SQL exploration and four-role blind review reasoning must strictly use masked placeholders like
PERSON_0001,ACCT_0001; real entity names are only restored locally by the deterministic script during the finalaudit_cli.py exportstage.
IRON RULE 2: Blinded Subagent Isolation
- In
full-auditmode, it is strictly forbidden to "role-play all four roles in a single model monologue" in the main conversation. - Must follow the state machine sequence, sequentially reading the corresponding role contract files under
agents/and spawning independent sub-agents (using the host'sinvoke_subagent/Task/Agenttools):- Initial Review:
agents/junior-auditor.md-> submit--role junior - Independent Review:
agents/challenger-auditor.md-> submit--role challenger - Fact Check:
agents/fact-checker.md-> submit--role factcheck - Final Review Partner:
agents/senior-partner.md-> submit--role senior
- Initial Review:
- Degradation Compatibility Rule: Only when the host environment does not support any sub-agent dispatch tools may the reviewer independently generate each role's JSON step-by-step in the main session, but each step must immediately call
audit_cli.py commitfor deterministic evidence graph verification, and steps must never be merged or skipped.
IRON RULE 3: Stateful CLI Gate & Minimum-Cut Rollback Closure
- Every role's conclusion must be submitted via
scripts/audit_cli.py commit --role <role>. If the state machine sequence is violated, the CLI will return exit code2(STATE_GUARD_VIOLATION). - When, after submitting
factcheck, the global consistency score $S_{\text{global}} < \theta$ (default0.80), the CLI will automatically execute dependency-aware minimum-cut local rollback, returning"rollback_triggered": truealong withrollback_diagnosis.arbitration_probe(review probe), and reverting the state toSTATE_JUNIOR_AUDITorSTATE_CHALLENGER_REVIEW. - When
rollback_triggered: trueis encountered, therollback_diagnosismust be injected into the target role and the sub-agent must be re-spawned until consistency is achieved and the state entersSTATE_SENIOR_PARTNER! Handwriting fake workpapers to skipexportis strictly forbidden.
III. Five Operational Mode Routing Table
Auto-select the corresponding mode based on user request (default executes full-audit):
| Mode Name | Applicable Scenario & Trigger Words | Execution Path |
|---|---|---|
full-audit(Default Full Workflow) | Audit account set file, comprehensive fraud/internal control deficiency check, and issue formal workpapers | Full execution of Section IV: 5-Step Stateful Protocol below (init $\to$ sql $\to$ 4-role blind review & minimum-cut rollback loop $\to$ export) |
quick-scan(Quick Scan) | "Quick scan for anomalies", "Don't run multi-agent game, just show rule scan results" | 1. Run audit_cli.py init --file <PATH> --case <ID> --mode quick2. Optionally run audit_cli.py export --case <ID> --out-dir <DIR> to quickly export rule scan workpapers |
sql-explore(SQL Sandbox Penetration) | Execute custom cross-period/grouped aggregation queries on an initialized account set | Run audit_cli.py sql --case <ID> --query "SELECT ... FROM financial_ledger ..." (read-only SELECT / WITH only) |
law-lookup(Hybrid Regulatory Retrieval) | "Look up standard clauses on split transactions/weekend entries/audit evidence" | Run audit_cli.py law --query "<keyword or question>" --top-k 5, outputs weighted evidence chain $E(q)$ and qualitative reasoning four-stage conclusion $\Psi$ directly |
workpaper(Workpaper Re-export) | Re-export for a completed case with different entity name, accounting period, or export directory | Run audit_cli.py export --case <ID> --entity-name "<Entity Name>" --period "<Period>" --out-dir <DIR> |
For detailed CLI parameters and JSON Schema, please refer to:
references/schemas.md.
IV. full-audit Standard 5-Step Stateful Execution Protocol
Assume the skill root directory is <SKILL_DIR> (containing scripts/audit_cli.py). If the user does not provide an account set file and requests a demo, the built-in high-fidelity fraud simulation sample account set <SKILL_DIR>/examples/sample_vouchers_2026.xlsx can be used directly.
Step 1: Initialize Account Set, Encrypt/Mask, and Run Deterministic Rules (init)
python3 <SKILL_DIR>/scripts/audit_cli.py init \
--file "<USER_EXCEL_OR_CSV_PATH>" \
--case "CASE_2026_01" \
--workspace ".auditcore_workspace" \
--lang "en"
- Record the returned JSON:
stats,schema_ddl,rule_findings,anomaly_samples,evidence_chain. - The state machine is now at
STATE_DYNAMIC_SQL_EXPLORATION.
Step 2: Read-Only SQLite Sandbox Penetration Query (sql)
Based on schema_ddl and rule_findings, write an aggregation review SQL for the masked financial_ledger table (e.g., review same-day split transaction counts and cumulative amounts for the same supplier, or aggregate abnormal amounts by debit account):
python3 <SKILL_DIR>/scripts/audit_cli.py sql \
--case "CASE_2026_01" \
--workspace ".auditcore_workspace" \
--query "SELECT Date, Vendor, COUNT(*) AS tx_count, SUM(Amount) AS total_amount FROM financial_ledger GROUP BY Date, Vendor HAVING tx_count >= 2 OR total_amount >= 100000 ORDER BY total_amount DESC"
- The state machine advances to
STATE_JUNIOR_AUDIT.
Step 3: Multi-Agent Independent Blind Review & Minimum-Cut Local Rollback Loop (commit Loop)
3.1 Spawn Junior Auditor (STATE_JUNIOR_AUDIT)
- Read
<SKILL_DIR>/agents/junior-auditor.md. - Spawn a sub-agent (or independent step), passing only masked
stats,rule_findings,anomaly_samples,sqlresults,evidence_chain(if a rollback retrial, additionally passrollback_diagnosis). - Get the JSON returned by the sub-agent (containing
analysis,risk_score,cited_reg_ids), submit to CLI:
python3 <SKILL_DIR>/scripts/audit_cli.py commit \
--case "CASE_2026_01" \
--workspace ".auditcore_workspace" \
--role junior \
--payload '<JUNIOR_JSON>'
- State machine advances to
STATE_CHALLENGER_REVIEW.
3.2 Spawn Independent Reviewer (STATE_CHALLENGER_REVIEW)
- Read
<SKILL_DIR>/agents/challenger-auditor.md. - Spawn an independent sub-agent, passing masked anomaly evidence,
evidence_chain, and the initial review'sjunior_reportandjunior_score, requiring it to independently review and challenge with professional skepticism. - Get the returned JSON (containing
rebuttal,adjusted_risk_score), submit to CLI:
python3 <SKILL_DIR>/scripts/audit_cli.py commit \
--case "CASE_2026_01" \
--workspace ".auditcore_workspace" \
--role challenger \
--payload '<CHALLENGER_JSON>'
- State machine advances to
STATE_FACT_CHECK.
3.3 Spawn Fact-Checker and Verify Global Consistency (STATE_FACT_CHECK)
- Read
<SKILL_DIR>/agents/fact-checker.md. - Spawn an independent sub-agent to perform atomic fact decomposition (
claims) and bipartite graph evidence mapping (evidence_mapping) on the initial and review conclusions. - Get the returned JSON (containing
analysis,support_score,conflict_score,conflict_type,claims,evidence_mapping), submit to CLI:
python3 <SKILL_DIR>/scripts/audit_cli.py commit \
--case "CASE_2026_01" \
--workspace ".auditcore_workspace" \
--role factcheck \
--payload '<FACTCHECK_JSON>'
- Check the CLI's returned
current_stateandrollback_triggered:- If
"rollback_triggered": true: Indicates a severe conflict in the evidence graph ($S_{\text{global}} < \theta$), the CLI has automatically pruned the worst reasoning subgraph and rolled back torollback_target_state(typicallySTATE_JUNIOR_AUDIT). You must extract the returnedrollback_diagnosis(containingarbitration_probeandcsa_guidance), go back to 3.1 (or 3.2) and re-spawn the sub-agent to correct the conclusion! - If
"current_state": "STATE_SENIOR_PARTNER": Indicates evidence graph consistency is met, proceed to Step 4.
- If
Step 4: Spawn Senior Partner for Final Adjudication and Audit Adjustment Entries (STATE_SENIOR_PARTNER)
- Read
<SKILL_DIR>/agents/senior-partner.md. - Spawn an independent sub-agent, passing masked statistics, regulatory evidence chains, verified initial/review conclusions, to generate the final verdict (
final_verdict,final_risk_score,reasoning,action_item,suggested_aje). - Submit to CLI:
python3 <SKILL_DIR>/scripts/audit_cli.py commit \
--case "CASE_2026_01" \
--workspace ".auditcore_workspace" \
--role senior \
--payload '<SENIOR_JSON>'
- State machine advances to
STATE_WORKPAPER_GENERATION.
Step 5: Assemble 4-Element Workpaper, Evaluate Quality $Q(Y)$, Reverse PII, and Export CSA-1131 Workpaper (export)
python3 <SKILL_DIR>/scripts/audit_cli.py export \
--case "CASE_2026_01" \
--workspace ".auditcore_workspace" \
--out-dir "./audit_outputs" \
--entity-name "Audited Entity" \
--period "FY2026"
- The CLI will automatically reverse-restore PII entity names and generate:
workpaper_docx_path: Formal.docxWord audit working paper compliant with Chinese Auditing Standard No. 1131;workpaper_markdown_path: Structured.mdaudit working paper;quality_evaluation: An evaluation report containing $Q_{\text{ev}}$, $Q_{\text{con}}$, $Q_{\text{cmp}}$, total score $Q(Y)$, and zero-tolerance hallucination check results.
- Report to the user the final audit findings, showing the restored real entity names, audit adjustment entries (AJE), quality score $Q(Y)$, and paths to the generated
.docx/.mdfiles.
V. Common Excuses & Anti-Laziness Comparison Table (Rationalization Table & Red Flags)
| Common Agent Laziness Excuse (Rationalization) | Objective Facts & Iron Rule Countermeasures (Reality & Iron Rule) |
|---|---|
"The account set file is small; let me use pandas.read_excel to quickly check the columns and suppliers inside." | Severe Violation (Violates IRON RULE 1)! Once the original file is read directly, plaintext entity names and bank accounts are immediately exposed in the LLM context, completely destroying privacy compliance boundaries. You must only run audit_cli.py init first. |
| "To save time, I'll write the JSON for the initial review, review, fact-check, and partner all in one code block and commit them sequentially." | Severe Violation (Violates IRON RULE 2)! Fabricating all four roles in a single context causes severe confirmation bias. If the host supports sub-agents, they must be spawned independently; even if executed sequentially, you must read the CLI's evidence graph feedback after each commit before proceeding. |
"After the factcheck commit triggered rollback_triggered: true, I'll just modify the score in the JSON and submit senior directly." | State gate directly intercepts (exit code 2)! After rollback, the state machine is at STATE_JUNIOR_AUDIT (or STATE_CHALLENGER_REVIEW). Without re-running the preceding roles per rollback_diagnosis.arbitration_probe, the state machine will never grant access to STATE_SENIOR_PARTNER. |
"I already know the audit conclusion; I can just write a Markdown report for the user, no need to call audit_cli.py export." | Severe Violation (Violates IRON RULE 3)! Handwritten reports cannot decrypt the real entity names in .vault_do_not_read.json (can only output PERSON_0001), and lack the patented four-element structure $Y={\text{idx},\text{aje},\text{jud},\text{log}}$, quality score $Q(Y)$, and the formal CSA-1131 .docx workpaper. |
Red Flags — When you have any of the following thoughts, stop immediately and return to the CLI protocol:
- About to run
pd.read_excel/pd.read_csv/open()to read the user's original financial file - About to read
.vault_do_not_read.json - Fabricating regulation article numbers in the analysis that do not appear in
evidence_chain(this triggershallucinated_citationszero-tolerance demotion, forcibly lowering $Q(Y)$ to $\le 0.40$) - Skipping
sqlor anycommit --rolestep and trying to directly runexport