claude-multi-agent-investing: Command for Claude Code

.claude/commands/rebalance.md

rebalance is a command for Claude Code from haiiibin/claude-multi-agent-investing. It costs 50 tokens per session (1,211 once invoked), scanned A, original, MIT.

A portfolio command that compares current investment holdings with target percentages and proposes trades to restore the intended mix.

In plain words
What is it for?
Use it to calculate ticker, sector, country, asset-class, and cash weights, then propose tax-ordered selling and buying when drift exceeds the configured thresholds.
Why use it?
Investments can drift away from their target weights as prices change. This command identifies those differences and separates rebalancing from investing newly available cash.

Command for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions CLAUDE.md.

This is haiiibin/claude-multi-agent-investing's own configuration. It tells Claude Code how to work on claude-multi-agent-investing itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-multi-agent-investing configures →

Reuse

Borrowing it

Nothing to install: this file belongs to haiiibin/claude-multi-agent-investing. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/haiiibin/claude-multi-agent-investing/main/.claude/commands/rebalance.md
Clone the repo
git clone --depth 1 https://github.com/haiiibin/claude-multi-agent-investing

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rebalance

README.md
[![agentmods](https://agentmods.dev/badge/commands/haiiibin/claude-multi-agent-investing/rebalance/github.svg)](https://agentmods.dev/commands/haiiibin/claude-multi-agent-investing/rebalance)
Your own site
<a href="https://agentmods.dev/commands/haiiibin/claude-multi-agent-investing/rebalance"><img src="https://agentmods.dev/badge/commands/haiiibin/claude-multi-agent-investing/rebalance/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rebalance

Your own site · 80×15
<a href="https://agentmods.dev/commands/haiiibin/claude-multi-agent-investing/rebalance"><img src="https://agentmods.dev/badge/commands/haiiibin/claude-multi-agent-investing/rebalance.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,211 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00050 $0.01211
Opus 5 $0.00025 $0.00606
Sonnet 5 $0.00010 $0.00242
Haiku 4.5 $0.00005 $0.00121

Measured 11d ago against content hash acf58613476a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

rebalance scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/rebalance.md · 120 lines

How it starts

The opening of the file, as written. The whole thing — 120 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/rebalance -- Drift-Based Rebalancing

/allocate-cash: "have cash, what to buy" | /rebalance: "positions drifted, trim winners + add laggards"

Input -- target weights

Priority order:

  1. Per-holding target_weight field in holdings.json
  2. Top-level targets: { sectors: {…}, asset_class: {…} } in holdings.json
  3. Arg override: /rebalance equal-weight | cap-weight | strategic 60/30/10
  4. None found: don't invent. Ask user which framework or which weights.

Phase 1 -- Current state

Journal pre-scan: Read memory/long_term/journal.md (if exists). Filter last 60 days. Flag any thesis-change tags for tickers still in portfolio → these become priority trim candidates in Phase 3, regardless of drift math.

Read holdings.json, aggregate by ticker cross-account. Compute:

  • MV per ticker (base currency), weight = MV / total_equity (cash excluded from denominator)
  • Cash weight separately (cash / total_portfolio)
  • Sector, country, asset-class weights
  • Drift per dimension vs target

Phase 2 -- Drift thresholds

  • Absolute drift: current - target
  • Relative drift: (current - target) / target
  • Trigger: abs >5pp OR rel >25%
  • Urgent: abs >10pp
  • Ignore: abs <2pp (micro-drift, not worth trading cost)

Phase 3 -- Propose trades

Over-weight → trim (tax-efficiency order)

  1. TFSA with gains → tax-free realization, trim first
  2. Taxable with unrealized loss → rebalance + harvest (double benefit; check 60-day superficial loss per CLAUDE.md)
  3. Taxable with short holding → at least not worse
  4. Taxable with large gain → trim last

State tax implication per sale (cite pooled ACB per CLAUDE.md, not per-account cost basis).

Under-weight → add (account selection)

  1. Currency match (USD→USD account)
  2. Account fit: zero-div growth→TFSA; US high-div→taxable USD (FTC); CAD div→CAD taxable (DTC)
  3. Sufficient cash in target account

If target is TFSA -- mandatory checks (prevent CRA 1%/month penalty):

  • Read accounts[].contribution_room_remaining. If null → warn user to verify at CRA My Account before buying.
  • Check memory/long_term/trades.md for same-year TFSA sells. If cash came from same-year withdrawal, room does NOT restore until Jan 1 next year. Refuse TFSA buy unless user confirms they understand.

Read the full file on GitHub · 120 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 120 lines · 50 tokens per session scan A acf58613476a

Subscribe to this mod's changes

rebalance is a command published in the GitHub repository haiiibin/claude-multi-agent-investing (2 stars, last pushed 20d ago), licensed MIT. It adds 50 tokens to every session and 1,211 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.