Files
stef-openclaw-skills/docs/us-cpa.md
2026-03-15 01:31:43 -05:00

5.8 KiB

us-cpa

us-cpa is a Python CLI plus OpenClaw skill wrapper for U.S. federal individual tax work.

Current Milestone

Current implementation now includes:

  • deterministic cache layout under ~/.cache/us-cpa by default
  • fetch-year download flow for the bootstrap IRS corpus
  • source manifest with URL, hash, authority rank, and local path traceability
  • authority ranking hooks for IRS materials and future primary-law escalation
  • case-folder intake and conflict-stop handling
  • question workflow with conversation and memo output
  • prepare workflow for the current supported 1040 subset
  • e-file-ready draft export payload generation

Review logic and broader form coverage are still pending.

CLI Surface

skills/us-cpa/scripts/us-cpa question --question "What is the standard deduction?" --tax-year 2025
skills/us-cpa/scripts/us-cpa question --question "What is the standard deduction?" --tax-year 2025 --style memo --format markdown
skills/us-cpa/scripts/us-cpa prepare --tax-year 2025 --case-dir ~/tax-cases/2025-jane-doe
skills/us-cpa/scripts/us-cpa review --tax-year 2025 --case-dir ~/tax-cases/2025-jane-doe
skills/us-cpa/scripts/us-cpa fetch-year --tax-year 2025
skills/us-cpa/scripts/us-cpa extract-docs --tax-year 2025 --case-dir ~/tax-cases/2025-jane-doe --create-case --case-label "Jane Doe" --facts-json ./facts.json
skills/us-cpa/scripts/us-cpa render-forms --tax-year 2025 --case-dir ~/tax-cases/2025-jane-doe
skills/us-cpa/scripts/us-cpa export-efile-ready --tax-year 2025 --case-dir ~/tax-cases/2025-jane-doe

Tax-Year Cache

Default cache root:

~/.cache/us-cpa

Override for isolated runs:

US_CPA_CACHE_DIR=/tmp/us-cpa-cache skills/us-cpa/scripts/us-cpa fetch-year --tax-year 2025

Current fetch-year bootstrap corpus for tax year 2025 is verified against live IRS irs-prior PDFs for:

  • Form 1040
  • Schedules 1, 2, 3, A, B, C, D, SE, and 8812
  • Form 8949
  • General Form 1040 instructions and selected schedule/form instructions

Interaction Model

  • question
    • stateless by default
    • optional case context
  • prepare
    • requires a case directory
    • if none exists, OpenClaw should ask whether to create one and where
  • review
    • requires a case directory
    • can operate on an existing or newly-created review case

Planned Case Layout

<case-dir>/
  input/
  extracted/
  return/
  output/
  reports/
  issues/
  sources/

Current implementation writes:

  • case-manifest.json
  • extracted/facts.json
  • issues/open-issues.json

Intake Flow

Current extract-docs supports:

  • --create-case
  • --case-label
  • --facts-json <path>
  • repeated --input-file <path>

Behavior:

  • creates the full case directory layout when --create-case is used
  • copies input documents into input/
  • stores normalized user-statement facts in extracted/facts.json
  • appends document registry entries to case-manifest.json
  • stops with a structured issue and non-zero exit if a new fact conflicts with an existing stored fact

Output Contract

  • JSON by default
  • markdown available with --format markdown
  • question supports:
    • --style conversation
    • --style memo
  • question emits answered analysis output
  • prepare emits a prepared return package summary
  • export-efile-ready emits a draft e-file-ready payload
  • review emits a findings-first review result
  • fetch-year emits a downloaded manifest location and source count

Question Engine

Current question implementation:

  • loads the cached tax-year corpus
  • searches a small IRS-first topical rule set
  • returns one canonical analysis object
  • renders that analysis as:
    • conversational output
    • memo output
  • marks questions outside the current topical rule set as requiring primary-law escalation

Current implemented topics:

  • standard deduction
  • Schedule C / sole proprietorship reporting trigger

Form Rendering

Current rendering path:

  • official IRS PDFs from the cached tax-year corpus
  • overlay rendering onto those official PDFs using reportlab + pypdf
  • artifact manifest written to output/artifacts.json

Current rendered form support:

  • Form 1040 overlay artifact generation

Current review rule:

  • overlay-rendered artifacts are marked reviewRequired: true

Preparation Workflow

Current prepare implementation:

  • loads case facts from extracted/facts.json
  • normalizes them into the current supported 2025 federal return model
  • computes the current supported 1040 subset
  • resolves required forms for the current supported subset
  • writes:
    • return/normalized-return.json
    • output/artifacts.json
    • reports/prepare-summary.json

Current supported calculation inputs:

  • filingStatus
  • wages
  • taxableInterest
  • businessIncome
  • federalWithholding

E-file-ready Export

export-efile-ready writes:

  • output/efile-ready.json

Current export behavior:

  • draft-only
  • includes required forms
  • includes refund or balance due summary
  • includes attachment manifest
  • includes unresolved issues

Review Workflow

Current review implementation:

  • recomputes the return from current case facts
  • compares stored normalized return values to recomputed values
  • checks whether required rendered artifacts are present
  • flags overlay-rendered artifacts as requiring human review
  • sorts findings by severity

Current render modes:

  • --style conversation
  • --style memo

Scope Rules

  • U.S. federal individual returns only in v1
  • official IRS artifacts are the target output for compiled forms
  • conflicting facts must stop the workflow for user resolution

Authority Ranking

Current authority classes are ranked to preserve source hierarchy:

  • IRS forms
  • IRS instructions
  • IRS publications
  • IRS FAQs
  • Internal Revenue Code
  • Treasury regulations
  • other primary authority

Later research and review flows should consume this ranking rather than inventing their own.