go-trader: Instructions file for Claude Code

CLAUDE.md

go-trader CLAUDE.md is an instructions file for Claude Code from richkuo/go-trader. It costs 4,578 tokens per session, scanned C, original, MIT.

A set of project instructions for Go Trader, a trading application written mainly in Go with Python tools for backtesting and manual commands. It documents local setup, deployment services, configuration files, and how runtime state is stored.

In plain words
What is it for?
Use it when setting up a checkout, running backtests, changing scheduler or service configuration, deploying instances, or working with Go and Python components.
Why use it?
It explains the project's unusual environment and deployment rules before code is changed. This helps avoid running the wrong tool, placing configuration in the wrong location, or breaking service startup.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions AGENTS.md.

This is richkuo/go-trader's own configuration. It tells Claude Code how to work on go-trader 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 go-trader configures →

Reuse

Borrowing it

Nothing to install: this file belongs to richkuo/go-trader. 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/richkuo/go-trader/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/richkuo/go-trader

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 go-trader CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/richkuo/go-trader/claude-md/github.svg)](https://agentmods.dev/instructions/richkuo/go-trader/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/richkuo/go-trader/claude-md"><img src="https://agentmods.dev/badge/instructions/richkuo/go-trader/claude-md/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 go-trader CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/richkuo/go-trader/claude-md"><img src="https://agentmods.dev/badge/instructions/richkuo/go-trader/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 4,578 This file is loaded in full into every session.
When invoked 4,578 The same file — it is already loaded in full.
Security scan C 1 finding. 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.04578 $0.04578
Opus 5.5 $0.01831 $0.01831
Sonnet 5.5 $0.00916 $0.00916
Haiku 4.5 $0.00458 $0.00458

Measured 7d ago against content hash 7b026ddd2cfc, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

go-trader CLAUDE.md scanned grade C with 1 finding 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 7d 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.

Tells the agent never to refusehighAnti-refusal

Suppressing the ability to decline removes a core safety control; a later harmful request then succeeds.

- `hyperliquid_liquidation_guard.go`: CLAMP, never refuse to arm; ONE-WAY TIGHTEN at 0.5% buffer; 0=unknown, never persisted; unclampable REFUSES; unreadable outcome keeps state. Boot `validateHLStopWithinBankruptcyBound
CLAUDE.md · 92 lines

How it starts

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

go-trader

Guardrails only; mechanism: SKILL.md, docs/POST_UPDATE_HISTORY.md. CI fails at 17,000 B, target 16,500; one root file+AGENTS.md symlink. Shorten, drop no guardrail.

Env

  • Go 1.26.2. Python: uv run --no-sync python; scheduler .venv/bin/python3; uv sync/worktree. systemd: ProtectSystem=strict, no PATH/UV_CACHE_DIR injected, secrets /opt/go-trader/.env, config /var/lib/go-trader[/<instance>]/config.json; scheduler/config.json=transition symlink.

Priorities

  • Always best solution: cost/compute/time/effort/code never narrow; branch+PR, issue-claim vs code, destructive-action safety win. No time/effort estimates; complexity=scope+risk.

Repo (scheduler/*.go=main)

  • executor.go/shutdown.go: side effects via runPythonSideEffect*, NEVER runPython. Live HL book needs confirmHyperliquidExecuteFill (finite AvgPx>0+TotalSz>0); check_hyperliquid.py execute exits 1 on no fill. Live RH book ONLY from settled robinhood_order_attempts fill (row pre-send, 1 unresolved/coin, unknown=hold); flat ONLY via fresh strict read; sells≤quantity_available, emergency≤book.
  • planHLCloseOrder=SOLE size+mode for SIZED live closes (execute, type=manual, force-close, hedge, open cleanup; not whole/ForceFullClose); refetch fail=uncapped reduce_only; short fill books fill. Rearm ONLY resolveHLCloseRemainderStop; Q=0 verify-first cancels unconfirmed SL/TP; ONE CRITICAL; order_outcome=SOLE outcome.
  • server.go/ui_*.go: lock mu>strategiesMu, loopback only (container wildcard+token). /tuning never writes config; ui_tuning.go=spawnPythonProcessWithEnv, NEVER runPython*; POST /api/tuning/apply=sole promotion. uiPartitionParam=sole ?partition= resolver: unparseable=400, unowned=404; diagnostics filter SourceRole pre paging+total; cash flow live_owned; selected correlation/portfolio-risk NEVER use untagged legacy.
  • config*.go: close_strategy canonical, unknown-key guard. On-chain TP gate!=len(tiers)>0. CircuitBreaker *bool via accessors ONLY. portfolio_risk.paper/paper_sources[].portfolio_risk: evaluators use partitionRiskConfig; nested paper rejected. portfolio_warning.go: paused off Top Contributors ONLY if flat (Quantity==0 regular+option).
  • close_defaults.go: system>user>strategy; explicit tp_tiers wins; applyUserCloseDefaultRatchetRegimeTrails runs in loadConfig BEFORE scalar ATR-stop default.
  • portfolio_scope.go/risk_partition.go: PortfolioScope from isLiveArgs=SOLE mode classifier; RiskPartition{Scope,Source} (live/paper/paper:<id>; paper_source=paper_sources id, never live)=SOLE risk+storage owner. New surface: activePartitions, filterStatesByPartition/strategiesInPartition, never roster.
  • state.go/db.go: SQLite-only, idempotent migrations. AppState.PortfolioRisk/CorrelationSnapshot=per-RiskPartition maps, read only via partitionRisk(IfPresent)/partitionCorrelation; initial_capital only via SetInitialCapital.
  • state_store*.go/storage_*.go: identity map immutable; 1 distinct file/partition; lock+save order primary>paper>sources by id. EVERY DB caller via StateStore (dbForStrategy, live-only liveFile); ids translate INSIDE StateDB; load maps (file,scope)->partition; diagnostics route by SourceRole, NEVER scope. New table=SKILL.md Storage Ownership row. Manual acks by ROW ID in-tx, NEVER high-water; book+queued row=ONE tx; failing rows end; unknown ownership errs BEFORE mutation; combined reads fail whole.
  • merge-paper-instance.sh: binaries on config COPIES; inspect/storage-inspect=LoadConfigReadOnly; both locks preflight>apply except --diff (config-only); --align-to-live writes only .aligned; compose lists ALL root-key conflicts, refuses; alias always via paper_alias.py; --once/--probe-only never proof; zero paper override inherits. channels/trade_alert_channels -paper keys skip if merged bare key routes there (=resolveChannel); dm_channels -paper/-paper:<id> NEVER skip; proof refuses paper DM route send path disagrees with.
  • risk.go: CheckRisk skips manual. Corrupt pos (qty/avgCost<=0)=zero-PnL *_corrupt leg, cash untouched. Latch: ONE owner per cycle+partition; DrawdownReadingSubstituted always labelled; untrusted over-limit defers, never vetoes. Paper equityTrusted always true. ResetPortfolioKillSwitchManual=sole DM reset; AutoResetConfirmedFlatKillSwitch/ClearLatchedKillSwitchSharedWallet ScopeLive only.
  • daily_loss.go: hold-only, UNLATCHED pure read, PRE-FEE realized PnL, never force-closes, per partition; new portfolio_risk gates copy it.
  • exposure_cap.go: blocking-only, direction-aware; one exposure model computeAssetDeltas (+ComputeCorrelation). notional_cap.go: hold-only via pausedBlocksSignal, never skips cycle, restart-required.
  • replay_{log,mirror}.go: DEFAULT-OFF, HL perps, flat-only hot-reload, 1 mirror/source.
  • hl_batch.go: shared-state failure=same-cycle per-strategy fallback, never blank close/SL/ratchet/protection/hedge; GO_TRADER_HL_BATCH=0 disables. Missing closed_bar_decision/htf_filter echo=script error, holds signal.
  • market_feed_*.go: role: feed runs BEFORE LoadConfig (no state/lock/probe). Seal bytes immutable; missed/evicted/pre-start key=unavailable, NEVER current data; sealer never takes mu. Consumer (websocket|shared): one sealed stdin marketSnapshot, paper funding=seal; missing frame=error, NEVER private fetch; 1 deadline/cycle, non-nil degraded snapshot, primary>backup. REST feed: /info via feedBudgetAcquire; key ready ONLY if refreshed that deadline. market_feed_correction.go: outside feedMu, closed bars only, never LastRecvAt/seals/readiness; ledger reasons correction(_retry).
  • migrate-service-layout.py/shared-feed-convert.sh: opt-in, NEVER run by update. Layout: target authoritative from enable-intent, recovery NEVER restarts source from stale snapshot; feed: failed switch restores byte copy.
  • hyperliquid_paper_funding*.go: paper HL book changes ONLY via mutatePaperPerpsBook; never DailyPnL/CB/losses; unresolved=held, NEVER booked 0.
  • hyperliquid_fills.go: HLFillLookup.Px=VWAP; ClosedPnLGross never into Trade.RealizedPnL; unconfirmed SL fills=gaps, never books.
  • hyperliquid_balance.go: hedge-leg rows private. pause.go: paused is NOT dueStrategies skip; pausedBlocksSignal holds pos-increasing at all 6 regime-gated sites (+per-scope persistence hold, HTF unavailable); closes/trailing SL/ratchet/protection pass.
  • regime*.go: stamp all 5 execute dispatches; strip sl_after pre ATR parse; regime_unified.go owns SL; directional policy DEFAULT-OFF; profile allocation flat-only; dynamic/divergence HL-live only. Trade-alert span=bundle spec (tradeAlertRegimeConfig): regime.timeframe else Args[2], NEVER sc.Timeframe; options own fixed spec, never cfg.Regime.
  • trailing_tp_ratchet.go: NO on-chain TP; HL perps+manual. hedge.go: HL perps only; ONE reconciler (hedgeTargetDecision+runHedgeSync); ownership ONLY Position.HedgeFor; PnL via RecordHedgeTradeResult, never RecordTradeResult; fail-closed unwind+CRITICAL DM. Both hot-reload-blocked while open; hedge backtester-rejected.
  • hurst_gate.go: DEFAULT-OFF, no shipped threshold, config.example.json clean; holds pos-increasing only, fail-closed FLAT-ONLY; metrics["hurst"] ONLY from composite classifier; stays in run_backtest.py stop_keys.
  • llm_entry_analysis.go: advisory-only; spawnPythonProcess NEVER runPython*; sole trade_diagnostics.llm_verdict writer.
  • scale_in.go: geometry frozen via RiskAnchorPrice, never blended AvgCost. manual*.go: kill-switch+CB gated; SL edits queue PendingManualAction (no bare book write; only re-arm/restore write); rejected close never assumes unconfirmed cancel spared trigger; verify-first SL+cancelled-TP restore, NEVER 2nd placement path; unverified=CRITICAL; adopted SL edits never gate; force-close live HL perps only.
  • hyperliquid_liquidation_guard.go: CLAMP, never refuse to arm; ONE-WAY TIGHTEN at 0.5% buffer; 0=unknown, never persisted; unclampable REFUSES; unreadable outcome keeps state. Boot validateHLStopWithinBankruptcyBound mirrors LoadConfig stop-owner resolution.
  • hyperliquid_protection.go: reduce-only; on-chain TP needs strategyUsesTieredTPATRClose+live=close_owner marker+echo (no echo=hold), NEVER nil CloseStrategy; evaluator fallback ONLY if nothing rests/armed+tiers unplaceable. SLAfterMoved: kept trigger ONLY, tighter-only; lost=CRITICAL. hyperliquid_shared_close_floor.go: <$10 shared-coin close escalates ONLY if each peer flat on-chain (refetched)+in book, before SL blocks, else ONE alert+hold; venue_rejected never resends; re-arm (7 owners) same-cycle ONLY after SUBMITTED cancel; 2nd refusal holds, any wording; manual guard skips queued-row symbol; failed-close owner re-arms SL leg ONLY, 3 blocks=CRITICAL; unknown TP place=armed, no re-place. Operator floor (decideOperatorSharedCloseFloor): same test+side+no larger, else refuse (no hold); unreadable mark skips escalation.
  • version_probe.go/probe_cmd.go: new runtime CLI flag>both probe argvs. agent_info.go: --bootstrap-md=AGENTS.generated.md, NEVER AGENTS.md. failure_alerts.go: wire notifier per new run*Check. discord_*commands.go: new mutating command: opsCommandNames+slashCommands()+dispatch.
  • shared_wallet*.go: PRE-FEE realized_pnl, net via tradeNetPnL*. Pool budgeting: 2+ live HL/OKX perps omit capital fields, margin_per_trade_usd>0; allocated-pool flat-only.
  • kill_switch_limit_orders.go: cancel each pending_limit_orders ROW pre-flatten; never gate reconcilePendingLimitOrders on kill-switch; cancel!=adoption, never auto-delete unadopted fill.
  • orphan_limit_cancel_alerts.go: cancel-only lane, status-FIRST finalize, books NO fill; orphanLimitCancelState=SSoT (off-book fill=UNTRACKED POSITION). limit_fill_exposure.go: books limit fill ONLY once live exposure confirms; per-coin aggregate, never per-row greedy; fail-closed same-dir+contained; unreadable/unbacked refuse book+block delete.
  • shared_scripts/: check scripts take --regime-payload-json, probed at start. Lot gate (floor, never full close): live partial=check_hyperliquid.py, no lot=no gate; HL perps paper (+opens/adds)=Go, sub-min/no lot=HOLD+no write+quiet cycle. platforms/<name>/adapter.py: 1 *ExchangeAdapter; HL _sz_decimals() via name_to_asset. funding_fetcher.py: merge_asof backward, DISJOINT funding_coverage; in-coverage gaps refill by strict download only, funding_venue_gaps=venue-absent (charge 0), failed refill writes nothing; regime.py ATR simple.
  • shared_strategies/: open SSoT open/registry.py; open/{spot,futures}/strategies.py=shims, never edit. Close: close/registry.py via from close_registry_loader import .., never bare import registry. hurst_exponent=SSoT.
  • HL tier parity: tp_model: resting_limit evaluators=buildHyperliquidProtectionPlan (SSoT tp_tier_parity.json); close_tier_fill_price paper-only; ladder load=validateTPTierLadders.
  • ledger_compare.py: sim tier close needs winning resting_fill; same costs.

Read the full file on GitHub · 92 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. 7d ago Changed · +1 lines · +6 tokens per session 7b026ddd2cfc
  2. 8d ago Changed · +35 tokens per session 6a1369c1cade
  3. 9d ago Changed · -12 tokens per session e72af6a2c686
  4. 20d ago Changed · +1 lines · +57 tokens per session 62dd1304f7c6
  5. 21d ago Changed · +1 lines · +9 tokens per session 021a46bf7064
  6. 22d ago Changed · -1 lines · +44 tokens per session c60c7bb2c650
  7. 23d ago Changed · +22 tokens per session 01c55ac514c7
  8. 24d ago Changed · -2 lines · -147 tokens per session d9abf6194559
  9. 27d ago Changed · +1 tokens per session 5356e9224c19
  10. 29d ago First seen · 92 lines · 4,563 tokens per session scan C e6da25380392

Subscribe to this mod's changes

go-trader CLAUDE.md is an instructions file published in the GitHub repository richkuo/go-trader (362 stars, last pushed today), licensed MIT. It adds 4,578 tokens to every session, about $0.0183 per session on Opus 5.5. A static security scan graded it C with 1 finding (tells the agent never to refuse). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other instructions, from other repositories

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 9,715 tokens

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,461 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, cache eligibility and rollout and applying the notice (cutover).

microsoft/vscode · 5,262 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,680 tokens

vscode copilot-instructions.md

Copilot instructions for microsoft/vscode, covering vs code copilot instructions, project overview, root folders, core architecture (src/ folder) and built-in extensions (extensions/ folder).

microsoft/vscode · 2,750 tokens

deepseek-harness AGENTS.md

AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.

deepseek-ai/deepseek-harness · 4,261 tokens