core-ai / helius-cli
CLAUDE.md30 starsChanged 12 days agoMITView on GitHub
CLI tool for managing Helius accounts and querying Solana blockchain data via the Helius platform. All data commands follow this pattern: 1. Create spinner (unless --json) 2. Resolve API key via resolveApiKey(options) — flag > env > config > JWT auto-resolve 3. Get SDK client via getClient(apiKey, network) 4. Call SDK method 5. Output: formatted terminal (chalk) or outputJson(payload) for --json. As of v1.3, outputJson() auto-wraps its argument in { ok: true, v: 1, data: <payload> } — callers still…
- Reads credentials
- Installs packages
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- helius-mcp/CLAUDE.mdCLAUDE.md
- helius-cli/llms.txtllms.txt
- helius-dflowSkill
- helius-jupiterSkill
- helius-okxSkill
- helius-phantomSkill
- heliusSkill
- svmSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
14 rules. About 0 are common, 2 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 45
All data commands follow this pattern:
- Very specific: line 46
Create spinner (unless --json)
- Distinctive: line 103
When adding a new error code:
- Very specific: line 104
Add it to ExitCode (pick the right range — 10-19 auth, 20-29 payment, etc.).
- Very specific: line 105
Add it to errorToExitCode.
- Very specific: line 106
Add it to exitCodeToCategory (pick the public Category).
- Very specific: line 107
Add a human-readable hint to CLI_GUIDANCE (required — suggestion is always present in JSON output.
- Very specific: line 142
Network display: When displaying the resolved network in output, always use resolveNetwork(options) — never options.network || "mainnet".
- Very specific: line 143
Removing local variables during refactors: When extracting inline code into a shared helper (e.g., replacing const network = …
- Very specific: line 144
Type annotations on generic wrappers: When wrapping SDK calls with generic utilities like withRetry<T>(), let TypeScript infer the return …
- Very specific: line 148
Create src/commands/mycommand.ts exporting async handler(s)
- Very specific: line 149
Use setupClient(spinner, options, "Loading message...") from src/lib/helius.js for the standard resolve → client → spinner pattern
- Very specific: line 151
Use handleCommandError(error, options, spinner) in the catch block — import from ../lib/output.js
- Very specific: line 153
Run pnpm build and verify
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 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.
Files
helius-cli
CLI tool for managing Helius accounts and querying Solana blockchain data via the Helius platform.
Directory Structure
bin/helius.ts # Entry point — Commander.js program, registers all commands
src/
commands/ # One file per command group
balance.ts # balance, tokens, token-holders
tx.ts # tx parse, tx history, tx transfers, tx scan, tx fees
asset.ts # 12 DAS API subcommands
account.ts # account info
network-status.ts # network status
block.ts # block by slot
wallet.ts # Wallet API (REST, not SDK) — identity, balances, history, transfers, funded-by
webhook.ts # webhook CRUD
program.ts # program accounts
stake.ts # staking commands
zk.ts # 24 ZK compression subcommands
send.ts # tx helpers (broadcast, raw, sender, poll, compute-units)
reclaim.ts # close empty SPL token accounts, reclaim rent (via Sender)
ws.ts # WebSocket streaming (account, logs, slot, signature, program)
config-cmd.ts # config show/set-api-key/set-network/set-project/clear
signup.ts # account signup (existing)
login.ts # wallet auth (existing)
projects.ts # list projects (existing)
plans.ts # list available plans and pricing
status.ts # account status: plan, credits, billing cycle
...
lib/
helius.ts # SDK client wrapper — resolveApiKey(), getClient(), restRequest(), HeliusHttpError
formatters.ts # formatSol(), formatAddress(), formatTimestamp(), formatTable()
config.ts # ~/.helius/config.json — jwt, apiKey, network, projectId
output.ts # ExitCode enum, classifyError(), handleCommandError(), outputJson(), exitWithError()
api.ts # Helius management API (signup, projects, API keys)
payment.ts # USDC payment for signup
wallet.ts # Keypair loading
constants.ts # VERSION, API_URL, treasury, USDC mintsCommand Pattern
All data commands follow this pattern:
- Create spinner (unless
--json) - Resolve API key via
resolveApiKey(options)— flag > env > config > JWT auto-resolve - Get SDK client via
getClient(apiKey, network) - Call SDK method
- Output: formatted terminal (chalk) or
outputJson(payload)for--json. As of v1.3,outputJson()auto-wraps its argument in{ ok: true, v: 1, data: <payload> }— callers still pass the raw payload. - Error: use
handleCommandError(error, options, spinner)— classifies the error, emits the error envelope ({ ok: false, v: 1, error_code, category, error, recoverable, suggestion, details? }) or spinner output, and exits with the classified exit code
Standard catch block template (all commands except ws.ts):
} catch (error) {
handleCommandError(error, options, spinner);
}handleCommandError() in src/lib/output.ts calls classifyError() internally, formats JSON or spinner output (with retryable hint), and exits with the classified exit code. All error output logic lives in this single function — do not duplicate it inline. Payment-specific errors (Insufficient SOL/USDC, Checkout failed/expired/timeout) are classified via keyword matching in classifyError().
WebSocket commands (ws.ts) use a variant that preserves the AbortError early-return and uses console.error instead of spinner.
API Key Resolution Chain
--api-key <key>CLI flagHELIUS_API_KEYenvironment variable~/.helius/config.json→apiKeyfield- Auto-resolve from JWT: fetch project details → first API key
Exit Code Ranges
- 0: success
- 1: general error
- 10-19: auth errors (NOT_LOGGED_IN=10, KEYPAIR_NOT_FOUND=11, AUTH_FAILED=12)
- 20-29: balance/payment errors (INSUFFICIENT_SOL=20, INSUFFICIENT_USDC=21, PAYMENT_FAILED=22)
- 30-39: project errors (NO_PROJECTS=30, PROJECT_NOT_FOUND=31, MULTIPLE_PROJECTS=32, PROJECT_EXISTS=33)
- 40-49: API errors (API_ERROR=40, NO_API_KEYS=41)
- 50-59: SDK/data errors:
- 50
NO_API_KEY— resolveApiKey() found nothing; permanent, fix config - 51
SDK_ERROR— unclassified SDK error - 52
INVALID_ADDRESS— bad base58/pubkey format; permanent - 53
INVALID_INPUT— bad parameters or HTTP 400; permanent - 54
INVALID_API_KEY— HTTP 401/403 or "invalid api key"; permanent, fix the key - 55
NOT_FOUND— HTTP 404 or resource not found; permanent - 56
RATE_LIMITED— HTTP 429 or rate limit message; transient, safe to retry - 57
SERVER_ERROR— HTTP 5xx or server error message; transient, safe to retry - 58
NETWORK_ERROR— ECONNREFUSED/ETIMEDOUT/fetch failed; transient, safe to retry
- 50
The recoverable field in --json error envelopes reflects this directly (renamed from pre-1.3 retryable).
New in v1.3: exit code 23 INSUFFICIENT_FUNDS — signup/upgrade paths where both SOL and USDC may be short; emit details.missing listing the shortfalls.
Output Envelope (v1.3)
All --json output goes through one of two shapes, defined in src/lib/output.ts:
- Success:
{ ok: true, v: 1, data: <payload> }—outputJson(payload)wraps automatically. - Error:
{ ok: false, v: 1, error_code, category, error, recoverable, suggestion, details? }— built bybuildErrorEnvelope()and written byhandleCommandError()/exitWithError().suggestionis always present (falls back to a generic "re-run with --debug" hint if the error code has noCLI_GUIDANCEentry).
Exported types: Envelope<T>, SuccessEnvelope<T>, ErrorEnvelope, Category.
When adding a new error code:
- Add it to
ExitCode(pick the right range — 10-19 auth, 20-29 payment, etc.). - Add it to
errorToExitCode. - Add it to
exitCodeToCategory(pick the publicCategory). - Add a human-readable hint to
CLI_GUIDANCE(required —suggestionis always present in JSON output; missing entries fall back to a generic "re-run with --debug" hint, which is agent-useless).
getExitCode() logs a debug() warning when handed an unknown code. Under --debug, run your command once; if you see the warning, the new code isn't wired up yet.
Streaming commands (ws.ts) do not use the envelope — they emit line-delimited { event, timestamp, data } via direct console.log. See the comment at ws.ts:10-13.
Error Classification
classifyError(error) in src/lib/output.ts returns { exitCode, errorCode, retryable } using three tiers:
HeliusHttpError(fromrestRequest()— wallet.ts REST path): exactstatusproperty → precise code- Status in message (Parsed Events and enhanced TX:
"Helius HTTP 429: ...", webhooks:"HTTP error! status: 429 - ..."): regex extracts status → same mapping - Keyword matching (RPC caller path — DAS, ZK, staking, raw, payment): matches phrases like
"insufficient sol","insufficient usdc","checkout failed","invalid api key","rate limit","not found","ECONNREFUSED",SyntaxError, etc.
restRequest() throws HeliusHttpError (defined in src/lib/helius.ts) so the REST path always hits Tier 1. The SDK paths hit Tier 2 or 3 depending on the client.
exitWithError() produces the same error envelope as handleCommandError() — both route through buildErrorEnvelope(). Caller-supplied details are nested under the envelope's details key so they can't collide with reserved fields (ok, v, error, error_code, category, recoverable, suggestion).
SDK vs REST
- SDK (
helius-sdk): DAS API, Parsed Events (tx parse,tx history,tx scanon mainnet;tx parseandtx historyfall back to enhanced transactions on devnet, where Parsed Events is unavailable), webhooks, staking, ZK compression, WebSockets, program accounts, priority fees - REST (
restRequest()): Wallet API (/v1/wallet/...) — identity, balances, history, transfers, funded-by
Build / Dev / Test
pnpm install
pnpm build # tsc → dist/
pnpm dev # tsx bin/helius.ts (runs directly)
node dist/bin/helius.js --helpCommon Pitfalls
exitWithError()json parameter: The 4th param defaults totrue. Always pass!!options.json— bareoptions.jsonisundefinedwhen the flag is absent, which falls through to thetruedefault and outputs JSON in terminal mode.- Network display: When displaying the resolved network in output, always use
resolveNetwork(options)— neveroptions.network || "mainnet". The Commander--networkflag has a default, butresolveNetwork()also checksHELIUS_NETWORKenv var and config file. - Removing local variables during refactors: When extracting inline code into a shared helper (e.g., replacing
const network = resolveNetwork(options)withsetupClient()), grep the rest of the function for references to the removed variable before deleting it. - Type annotations on generic wrappers: When wrapping SDK calls with generic utilities like
withRetry<T>(), let TypeScript infer the return type. Only addas anyat call sites where the SDK returnsunknownthrough the generic — not asconst result: anyon every call.
Adding a New Command
- Create
src/commands/mycommand.tsexporting async handler(s) - Use
setupClient(spinner, options, "Loading message...")fromsrc/lib/helius.jsfor the standard resolve → client → spinner pattern - Support
--jsonviaoutputJson()/ formatted chalk output - Use
handleCommandError(error, options, spinner)in the catch block — import from../lib/output.js - Register in
bin/helius.tswith Commander.js - Run
pnpm buildand verify
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
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.

