agentleFS
hugoguerraphugoguerrap/crypto-claude-desk/CLAUDE.md

crypto-claude-desk

CLAUDE.md32 starsChanged 5 months agoMITView on GitHub

A cryptocurrency analysis system built with Claude Code's native features: agents, MCP servers, and skills. All agents are spawned via the Task tool with subagent_type: general-purpose and an explicit model parameter. This ensures every subagent inherits all MCP tools from the parent conversation. The agent .md files in agents/ contain the analysis framework — include "Read agents/{name}.md for your full analysis framework" in the prompt. Why general-purpose? Plugin-defined agent types (e.g., crypto-trading-desk:market-monitor) don't receive MCP tools due to a known…

The file

We split this CLAUDE.md into the rules it gives an agent

7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask naturally and the coordinator routes by complexity:

    line 40
  2. Distinctive:

    Always include "Do NOT use the Edit tool" in every agent prompt.

    line 56
  3. Distinctive:

    Use for simple data points.

    line 59
  4. Very specific:

    Use for "analyze X" without explicit "full analysis" or "recommendation" request.

    line 75
  5. Very specific:

    Use for "full analysis", "should I buy", "recommendation", or /analyze.

    line 81
  6. Distinctive:

    IMPORTANT: Do NOT spawn all 5 agents at once.

    line 99
  7. Distinctive:

    NEVER over-delegate: If someone asks "price of BTC?", use one haiku agent.

    line 113

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Crypto Trading Desk - Multi-Agent Intelligence System

A cryptocurrency analysis system built with Claude Code's native features: agents, MCP servers, and skills.

Architecture

User Query
    |
    v
[Claude Code - Coordinator]
    |  Reads this CLAUDE.md
    |  Routes by complexity:
    |
    +-- QUICK (1 subagent) ----------> market-monitor (haiku)
    |
    +-- STANDARD (2-3 parallel) -----> market-monitor + technical-analyst + news-sentiment
    |
    +-- FULL ANALYSIS (5 subagents) -> 3 phases with file-based coordination
         Phase 1 (parallel): market-monitor || technical-analyst || news-sentiment
         Phase 2 (sequential): risk-specialist (reads Phase 1 files)
         Phase 3 (sequential): portfolio-manager (reads all, decides)

How to Use

First-Time Setup

  • /setup - Run once after installing. Detects environment, installs uv + Python deps, verifies MCP servers work. Cross-platform (macOS, Linux, Windows).

Slash Commands

  • /quick BTC - Fast market snapshot (1 agent, ~15 sec)
  • /analyze BTC - Full 5-agent analysis with trading decision (~3-5 min)
  • /portfolio - View portfolio status and open trades
  • /close-trade trade_001 - Close trade with post-mortem
  • /validate-predictions - Review pending predictions against market data
  • /monitor - Autonomous loop: check SL/TP, close trades, evaluate predictions
  • /create - Extend the system with new components

Natural Language

Ask naturally and the coordinator routes by complexity:

  • "How's BTC?" → Quick (market-monitor only)
  • "RSI of ETH?" → Standard (technical-analyst only)
  • "Analyze SOL" → Standard (2-3 agents)
  • "Full analysis of BTC with recommendation" → Full (5 agents in phases)
  • "Check my portfolio" → portfolio-manager
  • "Post-mortem on trade_003" → learning-agent

Routing Rules

How Delegation Works

All agents are spawned via the Task tool with subagent_type: general-purpose and an explicit model parameter. This ensures every subagent inherits all MCP tools from the parent conversation. The agent .md files in agents/ contain the analysis framework — include "Read agents/{name}.md for your full analysis framework" in the prompt.

Why general-purpose? Plugin-defined agent types (e.g., crypto-trading-desk:market-monitor) don't receive MCP tools due to a known Claude Code limitation (#4476). Using general-purpose with explicit model works in both plugin and local-clone modes.

Always include "Do NOT use the Edit tool" in every agent prompt.

Quick Query (single subagent via Task tool)

Use for simple data points. One agent, fast response.

Query TypeRoleModelKey MCP tools to mention in prompt
Price, volume, market overviewmarket-monitorhaikucrypto-exchange, crypto-data, crypto-futures
RSI, MACD, indicators, patternstechnical-analystsonnetcrypto-technical, crypto-advanced-indicators
News, sentiment, FUD/FOMOnews-sentimentsonnetWebSearch, WebFetch (no MCP needed)
Portfolio status, trade historyportfolio-manageropuscrypto-learning-db, crypto-exchange
Pattern lookup, pre-trade checklearning-agentopuscrypto-learning-db, crypto-data

Example delegation:

Task(subagent_type="general-purpose", model="haiku", prompt="You are the market-monitor agent. Read agents/market-monitor.md for your framework. Get BTC price using get_exchange_prices(symbol='BTC/USDT')... Do NOT use the Edit tool.")

Standard Analysis (2-3 subagents in parallel)

Use for "analyze X" without explicit "full analysis" or "recommendation" request. Launch 3 Tasks in parallel (all subagent_type: general-purpose):

  • market-monitor (model: haiku) + technical-analyst (model: sonnet) + news-sentiment (model: sonnet)
  • Coordinator synthesizes results

Full Analysis with Decision (5 subagents in phases)

Use for "full analysis", "should I buy", "recommendation", or /analyze. Spawn 5 subagents via the Task tool in 3 sequential phases (see /analyze skill for detailed prompts):

Phase 1 - Data Gathering (3 Tasks in parallel):

  • market-monitor (haiku) → data/reports/YYYY-MM-DD-{symbol}/market-data.md
  • technical-analyst (sonnet) → data/reports/YYYY-MM-DD-{symbol}/technical-analysis.md
  • news-sentiment (sonnet) → data/reports/YYYY-MM-DD-{symbol}/news-sentiment.md

Wait for all 3 Task calls to return. Verify files exist on disk.

Phase 2 - Risk Assessment (1 Task AFTER Phase 1):

  • risk-specialist (sonnet) reads Phase 1 files → data/reports/YYYY-MM-DD-{symbol}/risk-assessment.md

Wait for Task to return. Verify file exists.

Phase 3 - Decision (1 Task AFTER Phase 2):

  • portfolio-manager (opus) reads all files → data/reports/YYYY-MM-DD-{symbol}/decision.md

IMPORTANT: Do NOT spawn all 5 agents at once. Phase 2/3 agents MUST read files written by previous phases. Spawn them only after confirming previous phase files exist on disk.

Special Queries (single subagent)

  • "Close trade X" → portfolio-manager (close) + learning-agent (post-mortem + prediction validation)
  • "What patterns have we seen?" → learning-agent
  • "Check my predictions" → learning-agent via /validate-predictions
  • "Risk on my position?" → risk-specialist
  • "Monitor my trades" / "Check SL/TP" → /monitor (multi-agent coordination)
  • "Create a new MCP/agent/skill" → system-builder via /create

Delegation Rules

ALWAYS delegate via Task with subagent_type: general-purpose and explicit model. Include the agent's role and relevant MCP tools in the prompt. Don't call MCP tools directly from the main conversation.

NEVER over-delegate. If someone asks "price of BTC?", use one haiku agent. Don't spin up 5 agents for a simple question.

After every trade close, ALWAYS delegate to learning-agent for prediction validation. This is how the system learns.

Two Books — Spot vs Futures (Always Explicit)

The portfolio is split into TWO BOOKS with different mandates. Whenever you discuss a position, allocation, or new trade, always state which book. Never let the portfolio-manager pick a book by accident — it must justify the choice.

SPOT bookFUTURES book
JobLong-term conviction, ETF/narrative/on-chain playsTactical alpha, hedges, mean reversion, funding plays
HoldingDays to monthsHours to days
DirectionLong-biased (rare inverse setups)Long + short equally
Leverage1x always2-5x typical, max 10x
SL distance8-15% (let thesis breathe)2-4% (leverage compensates)
R/R min3:12:1
Max open53
Max allocated80% of spot balance30% of futures balance (margin)
Funding costNoneTracked per trade
Liquidation riskNoneComputed at entry

Book selection question for any new trade (the portfolio-manager must answer this explicitly):

  1. Multi-week thesis (narrative, ETF, upgrade, on-chain) → SPOT
  2. Multi-day technical setup at a specific level → FUTURES
  3. Hedge for existing spot exposure → FUTURES (short)
  4. Funding-rate harvest (delta-neutral) → FUTURES
  5. "Averaging down" a spot loss → STOP. Re-think or wait.

See agents/portfolio-manager.md § "Two Books, Two Mindsets" for the full rules.

Agents (7)

AgentRoleModelMCPsNative Tools
market-monitorFast market data, whale alerts, arbitrage scanhaikudata, futures, exchangeWebSearch, Read
technical-analystIndicators, patterns, signalssonnettechnical, advanced-indicators, exchange, data, learning-dbWebSearch, Read
news-sentimentNews + social sentiment + crowd psychology + market-priced consensussonnetlearning-db, polymarketWebSearch, WebFetch, Read
risk-specialistRisk, volatility, microstructure, institutional flows, on-chain capital flowssonnettechnical, microstructure, data, exchange, learning-db, defillamaWebSearch, Read
portfolio-managerFinal decisions + trade execution + Polymarket/on-chain sanity checkopusdata, learning-db, polymarket, defillamaRead, Grep, Write
learning-agentPredictions, patterns, post-mortemopusdata, learning-dbRead, Grep, Write
system-builderGenerate new MCP servers, agents, skills + testsopus(none)Read, Write, Grep, Glob, WebSearch, WebFetch

MCP Servers (9)

ServerToolsData Source
crypto-data11CoinGecko API (market metadata: fear/greed, dominance, rankings — NOT for live prices)
crypto-exchange15CCXT multi-exchange (orderbooks, OHLCV, volume, arbitrage)
crypto-technical14CCXT + calculated (RSI, MACD, Bollinger, patterns, signals)
crypto-futures10CCXT futures (funding rates, OI, long/short, liquidations)
crypto-advanced-indicators8CCXT (OBV, MFI, ADX, Ichimoku, VWAP, Pivot Points)
crypto-market-microstructure6CCXT (orderbook depth, imbalance, spoofing, market impact)
crypto-learning-db18SQLite (trades, predictions, patterns, summaries, track records, trade modifications)
crypto-polymarket6Polymarket Gamma API (prediction market probabilities — wisdom of crowds priced in real capital)
crypto-defillama7DefiLlama API (TVL by chain/protocol, stablecoin supply, DEX volume, on-chain capital flows)

Note: News and sentiment analysis uses WebSearch + WebFetch directly (Claude's native web intelligence) instead of MCP. This provides real-time breaking news, social sentiment from Twitter/Reddit, and semantic understanding superior to RSS-based keyword matching.

Skills (8)

SkillUsageDescription
/setup/setupFirst-time environment setup (cross-platform)
/analyze/analyze BTCFull 5-agent phased analysis with decision
/quick/quick ETHFast single-agent market check
/portfolio/portfolioPortfolio status and open trades
/close-trade/close-trade trade_001Close trade with post-mortem + learning
/validate-predictions/validate-predictionsReview pending predictions against market data
/monitor/monitorAutonomous loop: check SL/TP, close trades, evaluate predictions, generate summaries
/create/create a DeFi trackerExtend the system with new components (+ tests for MCP servers)

Design Decisions

  1. Hybrid routing — Quick queries use single subagents (cheap, fast). Full analysis uses 5 phased subagents (parallel where possible, sequential where needed).
  2. Model optimization — haiku for data scouts, sonnet for analysis, opus for final decisions. ~40-60% token savings vs all-sonnet. Model is passed explicitly via Task model parameter.
  3. General-purpose subagents — All agents use subagent_type: general-purpose to inherit MCP tools. Plugin agent types don't pass MCP tools to subagents (Claude Code #4476). Agent .md files define the analysis framework; the coordinator includes their instructions in the Task prompt.
  4. Persistent memory — portfolio-manager and learning-agent use memory: project to build institutional knowledge across sessions.
  5. File-based coordination — Agents write structured Markdown reports to a shared directory. Later-phase agents read those files before starting their analysis.
  6. Zero orchestration code — No Python coordinator, no Agent SDK. Claude Code is the coordinator via CLAUDE.md + agents/.
  7. Dual distribution — Works as a Claude Code plugin (claude plugin install) or as a local clone (--plugin-dir). Both modes use the same general-purpose delegation pattern.
  8. SQLite cognitive memory — Trades, predictions, and patterns stored in SQLite (data/db/learning.db). Agents query only what they need via crypto-learning-db MCP, preventing context window overflow. Scales to unlimited trades.

Cognitive Learning System

The system learns from every trade through a SQLite-backed cognitive memory (crypto-learning-db MCP server).

Storage: SQLite Database (data/db/learning.db)

TablePurpose
tradesAll open and closed trades with full metadata
predictionsTestable predictions from each agent (with NL evaluations)
trade_modificationsSL/TP change history with NL reasons
patternsNamed trading patterns with win rates
summariesMonthly/quarterly performance summaries
portfolio_stateCurrent balances and aggregate stats

Three Learning Layers

  1. Operational memory (SQLite queries): What the agent needs right now for a specific decision
  2. Strategic memory (summaries table): Compressed knowledge from past periods, generated via generate_summary()
  3. Meta-learning (get_prediction_track_record()): "How reliable is this type of setup in these conditions?"

Adaptive Learning (NL-driven)

The system learns through natural language reasoning, not formulas. MCP tools store data; agents do all interpretation.

  • validate_prediction(evaluation="...") stores the learning-agent's NL analysis of how close a prediction was and why. No formulas, no credit scores — just the agent's written reasoning.
  • get_prediction_track_record(symbol="...", strategy_type="...") provides setup-centric accuracy by time window (7d, 30d, 90d, global) PLUS recent NL evaluations. The key question is "how reliable is this setup?" not "how much do I trust this agent?"
  • find_expired_predictions() surfaces predictions past their timeframe with price context. The agent evaluates each one and validates.
  • portfolio-manager reads track records + evaluations and reasons in NL about setup reliability. Claude is the consensus engine.

Learning Loop

Open trade → record_trade() + record_prediction() → close trade → close_trade() + validate_prediction(evaluation="...") → NL evaluation stored → upsert_pattern() → generate_summary() periodically → next trade: get_prediction_track_record() returns setup accuracy + evaluations → agent reasons about setup reliability → find_expired_predictions() catches missed validations.

Headless / Autopilot Mode

Skills are NOT invoked via /skill-name in -p (print) mode. For scheduled execution via cron, use bin/autopilot.sh which maps workflow names to detailed natural language prompts:

./bin/autopilot.sh monitor           # Check SL/TP, close trades, evaluate
./bin/autopilot.sh quick "BTC ETH"   # Fast market snapshot
./bin/autopilot.sh analyze "BTC"     # Full 5-agent analysis
./bin/autopilot.sh portfolio         # Portfolio status

The wrapper handles PATH, working directory, tool permissions (--allowedTools), and logging.

Output Guidelines

  • Data-driven analysis with specific numbers
  • Actionable insights, not generic commentary
  • Risk parameters on every trade suggestion
  • Reports saved to data/reports/ for full analyses
  • Learning-agent builds pattern library over time via persistent memory

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.