Works with the AI Agents you already use
Wash-Sale & Tax-Aware Execution Auditor
by Sam3gp8
Audits trading bots and execution pipelines for IRS Section 1091 wash-sale violations and cost-basis errors, and installs a deterministic pre-trade tax gate. Ships a reference engine that passes 7/7 edge-case vectors.
$14.99
What it does
- Audits trading bots for IRS §1091 wash-sale violations and cost-basis errors
- Installs a deterministic SQLite pre-trade tax gate before orders hit your broker
- Catches 61-day window bugs, lookback blindness, and permanent IRA loss traps
- Verifies wash-sale mechanics offline against 7 bundled IRC §1091 test vectors
Who it's for
Algorithmic & retail bot builders
A persistent SQLite pre-trade gate that blocks wash-sale orders before they reach your broker API.
Try asking: “Audit my Alpaca rebalancing bot for wash-sale risk and add a pre-trade tax gate.”
Multi-account & IRA traders
Cross-account detection that catches permanent loss destruction when a taxable loss is replaced in an IRA.
Try asking: “Scan my execution pipeline for cross-account IRA replacement paths and lookback-window blind spots.”
Quant & tax-lot engineers
Exact 61-calendar-day windows, §1091(d) basis carryover, §1223 holding-period tacking, and 7/7 verified test vectors.
Try asking: “Wire wash_sale_engine.py and sqlite-tax-ledger.sql into my order router and run run_test_vectors.py.”
Wash-Sale & Tax-Aware Execution Auditor
Example session with this skill installed
Audit my Alpaca rebalancing bot for wash-sale risk and add a pre-trade tax gate.
- Read your context and instructions
- Compiled the wash-sale & tax-aware
Wash-Sale Risk Audit (rebalancer.py / broker.py)
| Severity | Location | Failure Mode | Tax Impact |
|---|---|---|---|
| CRITICAL | broker.py:submit_buy() | Rebalances into SPY inside linked Roth IRA 12 days after a taxable loss sale | Loss is permanently destroyed (no §1091(d) basis carryover into IRA) |
| HIGH | cooldown.py:is_blocked() | Uses 21 trading bars instead of exact 61 calendar days ([t - 30d, t + 30d]) | Rebuy on calendar day 29 triggers disallowance; day 31 is first safe rebuy |
| HIGH | ledger.py:LOSS_CACHE | Stores realized losses in an in-memory Python dict wiped on restart | Restarting the bot clears the 30-day lookback window and silently allows violations |
| MEDIUM | rebalancer.py:sell_lot() | Defaults to FIFO without Specific Identification or partial-share tracking | Over-triggers proportional disallowance on partial fills |
Drop-In Pre-Trade Tax Gate (tax_gate.py)
import sqlite3
from datetime import date, timedelta
from dataclasses import dataclass
@dataclass(frozen=True)
class GateDecision:
allowed: bool
reason: str
safe_after: date | None = None
def can_open_position(
conn: sqlite3.Connection,
symbol: str,
trade_date: date,
account_type: str = "taxable",
) -> GateDecision:
window_start = (trade_date - timedelta(days=30)).isoformat()
row = conn.execute(
"""
SELECT MAX(close_date) FROM realized_losses
WHERE symbol = ? AND close_date BETWEEN ? AND ?
""",
(symbol, window_start, trade_date.isoformat()),
).fetchone()
if row and row[0]:
last_loss = date.fromisoformat(row[0])
safe_date = last_loss + timedelta(days=31)
severity = "CRITICAL (IRA permanent loss)" if account_type == "ira" else "BLOCKED (§1091)"
return GateDecision(False, f"{severity}: loss on {last_loss}", safe_date)
return GateDecision(True, "CLEAR")
Bundled Reference Verification (scripts/run_test_vectors.py)
$ python3 scripts/run_test_vectors.py
[PASS] V1_exact_day_30_boundary (disallowed, basis carried)
[PASS] V2_day_31_first_safe_rebuy (allowed, 0 disallowed)
[PASS] V3_lookback_30d_prior_buy (backward window caught)
[PASS] V4_partial_share_proportional (proportional §1091(d) split)
[PASS] V5_holding_period_tacking (§1223 tacked dates verified)
[PASS] V6_year_end_straddle_dec_jan (cross-year deferral intact)
[PASS] V7_cross_account_ira_trap (flagged permanent loss)
RESULT: 7/7 VECTORS PASSED
Next Step: Initialize references/sqlite-tax-ledger.sql, wrap your Alpaca submit_order() call with can_open_position(), and run run_test_vectors.py in CI before live execution.
Connects securely to your tools. The creator never sees your data.
About this skill
Wash-Sale & Tax-Aware Execution Auditor turns your agent into a strict financial-systems auditor for U.S. tax-lot compliance (IRC §1091, §1091(d), §1223). It inspects trading codebases, finds tax-blind execution paths, and engineers a deterministic pre-trade gate before orders reach a brokerage API.
Catches the five failure modes that create phantom tax bills:
- Missing pre-trade tax gate (buys that never check a realized-loss ledger).
- Calendar-vs-trading-day bugs (bar counts / hardcoded 20–21 day windows instead of exact 61 calendar days).
- FIFO-only lot selection with no Specific Identification.
- Lookback blindness (blocking post-sale rebuys but ignoring the 30 days before).
- In-memory loss state that is wiped on restart.
Enforces the statutory mechanics correctly: the 61-day calendar window (day 31 is the first safe rebuy), loss-only scope, partial-share proportional disallowance, §1091(d) basis carryover, §1223 holding-period tacking, and the cross-account IRA trap (a loss replaced inside an IRA/Roth is permanently destroyed, not deferred).
Ships verifiable, not aspirational:
wash_sale_engine.py— a dependency-free reference implementation of the §1091 mechanics.run_test_vectors.py— runs it against every bundled edge-case vector; it ships green (7/7 passed).- A production SQLite lot-level ledger schema (both the backward and forward 30-day window edges) and deterministic test vectors covering boundary, straddle, lookback, partial-match, and IRA cases.
Enforces technical §1091 engineering mechanics; it is not legal, tax, or CPA advice.
Audits code and computes the §1091 engineering mechanics; it does not file taxes, connect to your broker, or replace a CPA. It enforces technical wash-sale mechanics and does NOT constitute legal, tax, accounting, or financial advice — verify all tax positions with a qualified professional. Spot crypto is treated as property (configurable via a feature flag), pending legislation.
Built for Claude Code, Cursor, ChatGPT, and MCP-compatible coding agents targeting Python 3.9+ and SQLite 3.35+. Bundled assets: • references/wash_sale_engine.py — Dependency-free Python reference implementation enforcing IRC §1091, §1091(d) basis carryover, §1223 holding-period tacking, partial-share disallowance, and cross-account IRA checks. • references/sqlite-tax-ledger.sql — Production SQLite lot-level ledger schema covering both backward and forward 30-day window edges (persists across bot restarts). • references/wash-sale-test-vectors.json — Deterministic edge-case suite covering boundary days (day 30 vs. day 31), straddles, lookback windows, partial matches, and IRA traps. • scripts/run_test_vectors.py — Offline CLI test runner that validates the engine against all 7 bundled vectors.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 8 days ago
- Software
Python 3.9+SQLite 3.35+
Permissions
Reads the trading codebase you point it at and runs the offline reference engine / test runner (Python 3.9+, stdlib only). No network calls; writes nothing outside the working directory.
What's inside
Frequently Asked Questions
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.