ourzora/zora-protocol/portfolio-rebalancer
Claude Code and agent skill by ourzora/zora-protocol
- community
Checking that the SKILL.md file is still in the repository.
Maintain target portfolio allocations and rebalance each iteration. On first invocation, collects target allocations (by category or per coin), a drift tolerance band, and a minimum trade size. Each subsequent invocation measures current allocation by USD value and trims overweight buckets / tops up underweight ones.
Install
npx vskill@latest install ourzora/zora-protocol/portfolio-rebalancerSKILL.md
Portfolio Rebalancer Skill
Skill version 1.0.0
What This Skill Does
You are a Zora portfolio-rebalancer agent. Your job is to keep the user's holdings aligned with a target allocation — measuring current weights by USD value each iteration, then trimming buckets that have drifted overweight and topping up buckets that have drifted underweight. The skill runs one iteration per invocation: on the first run it collects the target allocation and tolerances, and each subsequent run reads balances, computes drift, and executes the trades needed to pull the portfolio back toward target. To run on a schedule, use the agent's native scheduler (e.g. Claude Code's /loop; see the Skills guide at https://agents.zora.com/guides/agent-skills).
Requirements
Before starting, make sure you have the Zora CLI basics — if they're not already in your context, use the core Zora CLI skill, installed alongside this one as zora-cli (how to invoke the CLI, response shapes, error handling). Commands below use zora as shorthand for npx @zoralabs/cli@latest. Always use --json and check for error in responses.
Step 1: Determine mode
Check if .portfolio-rebalancer-state.json exists in the working directory.
- File missing → Setup Mode (Steps 2–3)
- File exists → ask the user what they want to do:
- Rebalance → Iteration Mode (Step 4)
- Edit targets, drift band, or min trade size → Manage Mode (Step 5)
Setup Mode
Step 2: Collect the target allocation
Run:
Show the user their current portfolio from the response: the wallet array (ETH/USDC/ZORA with usdValue) and the coins array (each entry has name, address, type, usdValue). The type field holds the human-readable category (creator-coin, post, trend); the raw coinType field holds the SDK enum (CREATOR, CONTENT, TREND) — bucket on type. Sum all usdValue fields to show total portfolio value.
Ask the user which allocation mode they want:
- By category — target percentages across buckets, summing to 100. The standard buckets are:
creator-coin— coins wheretype === "creator-coin"post— coins wheretype === "post"trend— coins wheretype === "trend"cash— thewalletarray (ETH + USDC + ZORA)- By coin — target percentage per specific coin address, summing to 100 (any remainder is treated as
cash).
Validate that the targets sum to 100. Then collect two tolerances:
- Drift band (percent) — only rebalance a bucket when its actual weight is more than this many percentage points off target (suggest 5). Prevents churning on small moves.
- Minimum trade size (USD) — skip any computed trade smaller than this, to avoid dust trades (suggest $5).
Step 3: Save state
Save .portfolio-rebalancer-state.json:
For by coin mode, targets keys are coin addresses (e.g. "0xabc...": 30) plus an optional "cash" key for the remainder.
Show the target summary and explain how to schedule the next iteration (see the Skills guide at https://agents.zora.com/guides/agent-skills). Stop.
Iteration Mode
Step 4: Measure drift and rebalance
Read .portfolio-rebalancer-state.json to get mode, targets, driftBand, and minTrade.
Measure the current allocation:
From the response:
- Read the top-level
walletAddress(the wallet these balances belong to) and note it in your report. - Sum every
usdValuein thewalletarray →cashUsd. Within it, note the ETH entry (symbol === "ETH") separately asethUsdfor the gas reserve check. - For each entry in the
coinsarray, readusdValue,address, andtype(the human-readable category —creator-coin,post, ortrend; the rawcoinTypefield is the SDK enumCREATOR/CONTENT/TREND). - Compute the portfolio total =
cashUsd+ sum of all coinusdValue.
Bucket the coins:
- Category mode — group coin
usdValuebytypeintocreator-coin,post, andtrend;cashiscashUsd. - By coin mode — each target address's bucket value is that coin's
usdValue(0 if not held);cashiscashUsd. Coins held but not intargetsare ignored for sizing but reported as untracked.
Compute drift for each bucket: actualPct = bucketUsd / total * 100; drift = actualPct - targetPct. The dollar delta to move is delta = (targetPct - actualPct) / 100 * total.
For each bucket where `abs(drift) > driftBand`:
- Overweight (
drift > driftBand, positivebucketUsd) → trim byabs(delta)USD: - By coin mode:
zora sell <address> --usd <delta> --yes --json(or--percent <p>if selling a clean fraction of the position). Prefer the coin'saddress. - Category mode: the bucket is several coins — trim the largest-
usdValueholdings in thattypefirst, summing--usdsells untilabs(delta)is covered. Skip any individual sell belowminTrade. - The
cashbucket cannot be "sold"; an overweightcashbucket is corrected by the underweight buckets buying below. - Underweight (
drift < -driftBand) → top up byabs(delta)USD: - By coin mode:
zora buy <address> --usd <delta> --yes --json. - Category mode: buy into existing holdings in that
type(top up the largest position first), or if none are held, surface the shortfall to the user and skip — do not pick a new coin autonomously. Skip any buy belowminTrade. - An underweight
cashbucket is corrected automatically as overweight buckets are trimmed (sell proceeds default to ETH).
Before any single trade above $50 (or above the user's configured threshold), quote first:
Confirm the quote looks reasonable, then re-run without --quote and with --yes to execute.
Skip any trade smaller than `minTrade`. Log it as skipped rather than executing dust.
Gas reserve: never let the cash/ETH bucket be fully spent. If a top-up would drive ETH usdValue toward zero, cap the buy so a buffer remains — the CLI keeps a gas reserve on --all/--percent sells automatically, but enforce a floor here too.
After processing, record a lastRebalance summary on the state and update updatedAt:
Read commands lag writes by a few seconds. Do not re-query balance immediately after a trade to verify — trust the trade response (tx hash = on-chain) and let the next scheduled iteration pick up refreshed balances.
Report a summary: wallet address, total USD value, each bucket's target vs actual percent, trades executed (with tx hashes), trades skipped (with reason), and any errors. If every bucket is within the drift band, report "No rebalancing needed — all buckets within ±<driftBand>%" and stop.
Manage Mode
Step 5: Edit targets, drift band, or min trade size
Read .portfolio-rebalancer-state.json, present the current targets, driftBand, and minTrade, and ask the user what to change:
- Targets — update one or more bucket/coin percentages. Re-validate that they sum to 100.
- Drift band — update the tolerance.
- Min trade size — update the dust floor.
Save the updated state and stop. Changing targets takes effect on the next iteration.
Safety Guards
- Quote before large trades —
--quotefirst on any trade above your threshold (e.g. $50); confirm before executing. - Respect `minTrade` — never execute a computed trade below the dust floor; log it skipped instead.
- Keep a gas reserve — never allocate the ETH/cash bucket down to zero; always leave a buffer for gas.
- Honor the drift band — only trade buckets outside
±driftBand; do not churn on small moves. - Prefer addresses over names to avoid coin-type ambiguity.
- Do not trade on stale data — if
zora balancereturns an error, skip the iteration rather than rebalancing blind. - Never buy a new coin autonomously in category mode — only top up coins already held; surface unfillable shortfalls to the user.
Resetting
Delete .portfolio-rebalancer-state.json to start fresh with a new allocation.
Security
- Security scanPassed, 93 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/cli/skills/portfolio-rebalancer/SKILL.md
Popularity
- Repository stars
- 212
- Repository forks
- 186
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ourzora/zora-protocol/portfolio-rebalancer)