Tax efficiency

From JoelLewis/finance_skills · View interactive version

Tax efficiency is an AI agent skill from the GitHub repository JoelLewis/finance_skills. Maximizes after-tax returns through strategic asset location, gain/loss management, and withdrawal sequencing. Use when the user asks about asset location, Roth conversions, tax-efficient withdrawals, tax lot selection, or charitable giving with appreciated securities. Also trigger when users mentio

How to use this skill

Skill file

Tax-Efficient Investing

Core Concepts

Asset Location

Place tax-inefficient assets in tax-advantaged accounts and tax-efficient assets in taxable accounts:

The benefit of asset location increases with the spread between ordinary income tax rates and capital gains rates, and with the size of the tax-advantaged accounts relative to total portfolio.

Tax-Loss Harvesting (TLH)

Realize investment losses to offset capital gains, reducing current tax liability while maintaining market exposure:

After-Tax Return

Different income types face different tax rates:

Tax Drag

The annual cost of taxes on investment returns:

Tax Lot Management

When selling partial positions, the method of selecting which lots to sell affects tax liability:

Roth Conversion

Convert Traditional IRA/401k assets to Roth, paying ordinary income tax now for tax-free growth and withdrawals later:

Required Minimum Distributions (RMDs)

Mandatory annual withdrawals from tax-deferred accounts (Traditional IRA, 401k) beginning at age 73 (under SECURE 2.0, rising to 75 in 2033):

Withdrawal Sequencing

The order of withdrawals from different account types in retirement:

Charitable Giving Strategies

Key Formulas

| Formula | Expression | Use Case |

|---------|-----------|----------|

| After-tax return (income) | R_at = R × (1 - t) | Bond/interest income after tax |

| After-tax return (deferred gains) | R_at = ((1 + R)^n × (1 - t_cg) + t_cg)^(1/n) - 1 | Unrealized equity with deferral benefit |

| Tax-loss harvesting value | TLH_value = loss × marginal_tax_rate | Immediate tax benefit of harvesting |

| Roth conversion breakeven | t_now < t_future | Convert when current rate < future rate |

| RMD amount | RMD = balance_Dec31 / distribution_period | Required minimum distribution |

| Appreciated-stock donation benefit | Tax saved = FMV × t_income + gain × t_cg_avoided | Tax benefit of donating appreciated stock (deduction + avoided gains tax) |

Worked Examples

Example 1: Asset location optimization

Given: $500K in taxable brokerage + $500K in Traditional IRA. Portfolio target: 50% bonds (yielding 5%) and 50% equities (expected 10% total return, 2% qualified dividends). Marginal tax rate: 32% ordinary, 15% LTCG.

Calculate: Optimal asset placement and annual tax savings vs naive allocation.

Solution:

  1. Optimal placement: Bonds ($500K) in IRA; Equities ($500K) in taxable.
  2. Naive placement (50/50 each): Taxable has $250K bonds + $250K equities; IRA has $250K bonds + $250K equities.
  3. Tax drag — naive: Taxable bonds: $250K × 5% × 32% = $4,000. Taxable equity dividends: $250K × 2% × 15% = $750. Total tax = $4,750.
  4. Tax drag — optimal: Taxable equity dividends only: $500K × 2% × 15% = $1,500. Total tax = $1,500.
  5. Annual tax savings: $4,750 - $1,500 = $3,250/year (0.325% of total portfolio).
  6. Over 20 years compounded, this adds significantly to after-tax wealth.

Example 2: Roth conversion breakeven

Given: Consider converting $50,000 from Traditional IRA to Roth. Current marginal tax rate: 24%. Tax on conversion paid from outside funds. Investment horizon: 20 years. Expected return: 7%.

Simplifying assumption: Assume the $12,000, if not used for conversion tax, would grow at the same 7% with no tax drag — i.e., side-fund growth itself is untaxed.

Calculate: Future marginal tax rate at which conversion breaks even.

Solution:

  1. Cost of conversion now: $50,000 × 24% = $12,000 tax paid today.
  2. Traditional IRA path: $50,000 grows to $50,000 × (1.07)^20 = $193,484. After-tax at withdrawal: $193,484 × (1 - t_future).
  3. Roth path: $50,000 grows to $193,484 tax-free, but the $12,000 side fund forgoes growth to $12,000 × (1.07)^20 = $46,436. Roth net value: $193,484 - $46,436 = $147,048.
  4. Breakeven: Set Traditional after-tax = Roth net value. $193,484 × (1 - t_future) = $193,484 - $46,436 → t_future = $46,436 / $193,484 = 24.0%.
  5. Conclusion: Under this simplification the breakeven future rate equals the current rate (24%) — both sides scale by the same (1.07)^20, so the horizon and return cancel. In reality the taxable side fund suffers tax drag on its dividends and realized gains, so paying conversion tax from outside funds tilts the comparison toward Roth even when the future rate merely equals the current rate.

Common Pitfalls

Cross-References

Running the script

Run with uv run scripts/tax_efficiency.py (the PEP 723 header resolves dependencies automatically) or with python3 scripts/tax_efficiency.py after pip install numpy scipy. The bare run prints a demo covering after-tax returns, tax drag, TLH benefit, asset location placement, and Roth conversion breakeven. Pass --verify to assert the demo outputs match this skill's worked examples (prints PASS/FAIL), or --help for an overview of the available classes. The file is primarily meant to be imported as a module (e.g., from tax_efficiency import AfterTaxReturn, AssetLocation, BreakevenAnalysis).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.