SQL
AuraScore 83/100

Federal Grant Compliance and Expenditure Audit SQL Brief

Design production-ready SQL audit pipelines to detect grant misallocations and enforce public sector accounting compliance rules.

Use this template when municipal or state agencies must reconcile grant disbursements against strict allowable cost schedules. It guides the creation of auditable SQL queries and exception-flagging data models for oversight reviews.

Template

Role: Principal Public Sector Data Architect specializing in statutory grant accounting and automated compliance audit systems.

Context

  • Target Grant Program: {{grant_program_name}}
  • Database Engine & Dialect: {{sql_dialect}}
  • Audited Fiscal Interval: {{fiscal_period}}
  • Statutory Compliance Framework: {{compliance_rules}}
  • Flagged Cost Classifications: {{disallowed_cost_codes}}

Task

Generate a comprehensive SQL compliance audit brief that specifies production-ready, auditable SQL queries to isolate unallowable expenditures, quantify funding caps, and construct automated discrepancy views for {{grant_program_name}}.

Method

  1. Parse the structural parameters of {{compliance_rules}} and map them against transactional tables in {{sql_dialect}}.
  2. Design Common Table Expressions (CTEs) that filter raw expenditure ledger rows strictly for {{fiscal_period}}.
  3. Establish conditional logic using CASE statements to flag transactions matching {{disallowed_cost_codes}}.
  4. Build cumulative window functions (SUM() OVER (...)) to track running expense totals against statutory program appropriation ceilings.
  5. Implement anti-join and existence subqueries to detect missing vendor documentation, unapproved purchase orders, and orphaned accounting entries.
  6. Format query outputs into distinct compliance risk tiers with deterministic categorization codes.
  7. Structure final validation aggregation views suitable for integration into public reporting dashboards.

Constraints

  • MUST produce syntactically valid SQL conforming strictly to {{sql_dialect}} specifications.
  • MUST NOT use non-deterministic functions that inhibit query reproducibility during external audits.
  • All calculated monetary values MUST round using standard accounting precision rules (two decimal places).
  • Inline comments must accompany every CTE explaining the statutory rule being enforced.
  • Code must avoid vendor-specific locking hints unless necessary for read-only replica performance.

Output format

Provide a markdown brief containing:

  1. Executive Accounting Schema & Assumption Matrix (1 table, max 8 rows)
  2. CTE Architecture & Data Lineage Breakdown (bulleted list)
  3. Production SQL Query Script (fully commented, syntax-highlighted code block)
  4. Discrepancy Reconciliation & Verification Guide (max 300 words)

Self-review

  • Confirm every cost code from {{disallowed_cost_codes}} is accounted for in query logic.
  • Verify all date logic strictly isolates records to {{fiscal_period}} without off-by-one errors.
  • Ensure dialect-specific syntax matches {{sql_dialect}} standards without generic pseudo-SQL.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

data-analytics
data-sql
public-sector-nonprofit
sql
compliance
grants