go-trader CLAUDE.md

go-trader CLAUDE.md is an instructions file for coding agents from richkuo/go-trader. It costs 3,912 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

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/richkuo/go-trader/claude-md
Clone the repo
git clone --depth 1 https://github.com/richkuo/go-trader

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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 3,912 This file is loaded in full into every session.
When invoked 3,912 The same file — it is already loaded in full.
Security scan C 1 finding. Scan, not verified.
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.03912 $0.03912
Opus 5 $0.01956 $0.01956
Sonnet 5 $0.00782 $0.00782
Haiku 4.5 $0.00391 $0.00391

Measured today against content hash bdb15d5af1a8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, 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 today.

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 `validateHLStopWithinBankruptc
CLAUDE.md · 95 lines

How it starts

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

go-trader Project Context

Coding guardrails only. Mechanism detail: SKILL.md § Subsystem Mechanism Reference; operator flows: SKILL.md, docs/POST_UPDATE_HISTORY.md. Docs syncs keep this file under 15,000 bytes and never split it (agents auto-load only the root CLAUDE.md; AGENTS.md symlinks to it): shorten wording to fit, never delete a guardrail.

Environment

  • Go 1.26.2 (/opt/homebrew/bin/go). Python via uv run --no-sync python; the scheduler calls .venv/bin/python3. uv sync per worktree.
  • systemd units: ProtectSystem=strict, no PATH/UV_CACHE_DIR injection; secrets in /opt/go-trader/.env. Deployed config lives OUT of the tree at /var/lib/go-trader[/<instance>]/config.json; scheduler/config.json is a transition symlink. SKILL.md § Configure.

Decision Priorities

  • Always pursue the absolute best technical solution. Cost, compute, time, effort, tests, and code volume never narrow the option space, and never override the branch+PR workflow, verifying issue claims against code, or destructive-action safety.
  • Never give time, duration, or effort estimates. Describe complexity by scope and risk only.

Repo Structure (scheduler/ is one Go package main)

  • executor.go/shutdown.go: new side-effecting wrapper → runPythonSideEffect, NEVER runPython. confirmHyperliquidExecuteFill gates every live HL book path: Execution.Fill with finite AvgPx>0 and TotalSz>0, else no book. check_hyperliquid.py execute exits 1 on unconfirmed fill.
  • server.go/ui_*.go: lock order mu → strategiesMu (reusing mu deadlocks SIGHUP). Loopback only. /tuning never writes config; ui_tuning.go uses spawnPythonProcessWithEnv (NEVER runPython*); POST /api/tuning/apply is the sole promotion.
  • config.go/config_migration.go: CurrentConfigVersion=19, MinSupportedConfigVersion=13. Seven mutually-exclusive HL stop fields (all omitted → DefaultStopLossATRMult=1.0); close_strategy canonical; unknown-key guard. strategyUsesTieredTPATRClose(sc) gates on-chain TPs, NOT len(tiers)>0. CircuitBreaker *bool ONLY via accessors. portfolio_risk.paper: every evaluator takes scopeRiskConfig, never cfg.PortfolioRisk; nested paper.paper rejected.
  • close_defaults.go: system→user→strategy; explicit tp_tiers wins; applyUserCloseDefaultRatchetRegimeTrails runs in loadConfig before the scalar ATR-stop default.
  • portfolio_scope.go: PortfolioScope from isLiveArgs is the single mode classifier (strategyMode retired). activeScopes evaluates ONLY configured scopes. New portfolio-wide surface → subset with filterStatesByScope/strategiesInScope, never the whole roster.
  • state.go/db.go: SQLite-only, idempotent migrations. AppState.PortfolioRisk/CorrelationSnapshot are per-scope maps read via scopeRisk/scopeRiskIfPresent/scopeCorrelation, never bare. initial_capital only via StateDB.SetInitialCapital.
  • risk.go: CheckRisk skips manual. Corrupt position (qty≤0 or avgCost≤0) → zero-PnL *_corrupt leg, cash untouched. Portfolio latch: ONE owner per cycle per scope; DrawdownReadingSubstituted labelled everywhere; untrusted over-limit defers, never vetoes. Paper equityTrusted is always true. ResetPortfolioKillSwitchManual is the sole DM reset. Live-only auto-clear: AutoResetConfirmedFlatKillSwitch, ClearLatchedKillSwitchSharedWallet touch ScopeLive only. SKILL.md § Portfolio Kill Switch And Latch Ownership.
  • daily_loss.go: hold-only, UNLATCHED pure read, PRE-FEE realized PnL, never force-closes, per scope. New portfolio_risk gate → copy this shape (SKILL.md § Risk, latch, and the portfolio gates).
  • exposure_cap.go: blocking-only, direction-aware; single exposure model computeAssetDeltas shared with ComputeCorrelation. notional_cap.go: hold-only via pausedBlocksSignal, never skips the strategy cycle; restart-required.
  • replay_log.go/replay_mirror.go: DEFAULT-OFF; HL perps, flat-only hot-reload; one mirror per source (replayMirrorSourceID).
  • hl_batch.go: shared-state failure ⇒ per-strategy fallback same cycle; never blank a close/SL/ratchet/protection/hedge. GO_TRADER_HL_BATCH=0 disables.
  • hyperliquid_fills.go: fill resolver built outside mu.Lock; HLFillLookup.Px=VWAP; ClosedPnLGross never into Trade.RealizedPnL; unconfirmed SL fills are gaps, not books.
  • hyperliquid_balance.go: reconciliation-close alerts outside mu; hedge-leg rows never reach the public route.
  • pause.go: paused is NOT a dueStrategies skip. pausedBlocksSignal holds position-increasing signals at all 6 regime-gated dispatch sites; closes/trailing SL/ratchet/protection pass.
  • Regime (regime*.go): stamp all 5 execute dispatches; strip sl_after before ATR parse; regime_unified.go owns SL; directional policy DEFAULT-OFF, exact-match certs; profile allocation flat-only; dynamic/divergence HL-live-only.
  • trailing_tp_ratchet.go: NO on-chain TP; HL perps+manual; hot-reload blocked while open.
  • hedge.go: HL perps only; ONE reconciler (hedgeTargetDecision+runHedgeSync); ownership Position.HedgeFor ONLY; hedge PnL → RecordHedgeTradeResult, never RecordTradeResult; fail-closed unwind + CRITICAL DM; hot-reload blocked while open; backtester rejects.
  • hurst_gate.go: DEFAULT-OFF, no shipped threshold, config.example.json clean; holds position-increasing signals only; fail-closed FLAT-ONLY; metrics["hurst"] ONLY from the composite classifier; keep in run_backtest.py stop_keys.
  • llm_entry_analysis.go: advisory-only; spawnPythonProcess NEVER runPython*; sole writer of trade_diagnostics.llm_verdict. trade_diagnostics*.go never write it.
  • scale_in.go: geometry frozen via RiskAnchorPrice, never blended AvgCost. manual*.go: kill-switch+CB gated; SL edits queue PendingManualAction, NEVER direct UPDATE; 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. SKILL.md § Hyperliquid Liquidation Guard.
  • hyperliquid_protection.go: reduce-only; on-chain TP only when strategyUsesTieredTPATRClose AND live (paper never). hyperliquid_open_trailing.go arms the initial SL at open.
  • version_probe.go/probe_cmd.go: new runtime CLI flag → both probe argvs; ExitProbeFailure=78.
  • agent_info.go: --bootstrap-mdAGENTS.generated.md, NEVER AGENTS.md.
  • failure_alerts.go: wire the notifier on each 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, positive margin_per_trade_usd each; allocated↔pool flat-only. cashflow_journal.go OUTSIDE mu.
  • kill_switch_limit_orders.go: cancel every pending_limit_orders row BEFORE flatten (keyed on ROW); never gate reconcilePendingLimitOrders on kill-switch; cancel≠adoption; never auto-delete an unadopted fill.
  • orphan_limit_cancel_alerts.go: cancel-only lane, status-FIRST finalize, books NO fill; orphanLimitCancelState is the SSoT (off-book fill = UNTRACKED POSITION). limit_fill_exposure.go: book a limit fill ONLY after live exposure confirms; per-coin aggregate, never per-row greedy; fail-closed same-direction+contained; unreadable/unbacked refuse book AND block row delete.
  • shared_scripts/: every check script accepts --regime-payload-json, probed at startup. platforms/<name>/adapter.py: one *ExchangeAdapter per file; HL _sz_decimals() resolves via name_to_asset(symbol) first. shared_tools/funding_fetcher.py: merge_asof backward, DISJOINT funding_coverage; regime.py ATR pinned simple.
  • shared_strategies/: open SSoT open/registry.py; open/{spot,futures}/strategies.py are shims, do not edit. Close via close/registry.py, imported with from close_registry_loader import …, never bare import registry. hurst_exponent (DFA) is the live SSoT.

Read the full file on GitHub · 95 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. today Changed · -56 lines · -4,628 tokens per session bdb15d5af1a8
  2. yesterday Changed · +6 lines · -873 tokens per session edfcc1fb9d9e
  3. 6d ago First seen · 145 lines · 9,413 tokens per session scan C 06f416ad24a8

Subscribe to this mod's changes

go-trader CLAUDE.md is an instructions file published in the GitHub repository richkuo/go-trader (345 stars, last pushed today), licensed MIT. It adds 3,912 tokens to every session, about $0.0196 per session on Opus 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

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

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 · 6,785 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 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,296 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,469 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, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens