/algo-trading-skills:token-lifecycle-live-probingfrom algo-trading-skills
Probes cached broker tokens to determine actual usability before trading calls, handling three outcomes to avoid needless re-authentication when documented expiry times are unreliable.
Ships in algo-trading-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Invoke this whenever bot startup logic needs to decide "reuse cached token" vs "re-authenticate." Do not use a documented expiry timestamp as the sole source of truth for whether a token works.
The timestamp is untrustworthy for reasons you can verify, not just folklore. Kite Connect's access token expires at 6 AM the next day, but its documentation also states the token dies early if it is "invalidated using the API, or invalidated by a master-logout from the Kite Web trading terminal" — neither of which your bot observes. Fyers publishes a 15-day refresh-token lifetime but no time-of-day at all for the access token, so any TTL constant you write for Fyers is a guess. ICICI Breeze expires at 24 hours or midnight, whichever comes first, so the same token has two different deadlines depending on when it was issued. A cached timestamp cannot model any of that; a probe does not have to.
Then get the third outcome right, because that is where this goes wrong in production. A probe that does not come back is not a probe that says "dead". A timeout, a 5xx, or a 429 tells you nothing about the token, and re-authenticating on it aims a login attempt at a broker that is already degraded — against the endpoint most likely to throttle you next. The recovery from a five-minute outage becomes a lockout that outlasts it.
headless-broker-auth-patterns.kill-switch-and-drawdown-circuit-breakers.GET /funds reads and POST /funds sets funds allocation, on the same path.references/standards.md. The defaults
(401/403 invalid, 408/425/429 retryable) are not universal."s": "error" bodies), a body classifier — a status-code check alone will read those
as healthy.probe_fn that catches its own transport errors and returns (None, True),
rather than letting requests raise through the retry loop.403 TokenException, Fyers 401 with "code": -16) → trigger full
re-authentication immediately.400 as bad parameters, 404 as a missing
resource, 405 as a wrong method and 410 as gone; every one of those is a
client or config defect that re-authentication cannot fix, and guessing
"invalid" spends a login on a bug in your own request.verify_and_refresh_token raises
AmbiguousProbeError rather than falling through to reauth_fn, and hands the
cached token back on the exception so the caller can keep it.headless-broker-auth-patterns), then re-probe the new token before marking the
bot ready to trade.
TokenVerificationError carries the new token so it can be persisted
before the caller retries.should_proactively_refresh defaults to 3 samples and a
30-minute margin.Full step-by-step procedure with broker-specific detail: see
references/workflows.md. Broker/framework coverage table and sources for this skill: seereferences/standards.md. Printable pre-flight checklist: seeassets/checklist.md.
if now < token_issued_at + documented_ttl: reuse token and skipping
the live probe entirely. This is the exact anti-pattern this skill exists to
prevent. For Fyers there is no documented TTL to check against in the first place.probe_fn that returns bool has already
lost the distinction — false then means both "revoked" and "the broker did not
answer", and only one of those warrants a login.429 as invalidity. Kite documents 429 as "Too many requests to
the API (rate limiting)"; Fyers returns 429 request limit reached. Re-authenticating
because you were rate-limited is the fastest route to being rate-limited harder.funds endpoint is a
read on GET and a funds-allocation write on POST. "It's the funds endpoint,
it's read-only" is true only of one of the two.{"Success": ..., "Status": <http-style code>, "Error": ...}, so an expired
Breeze session can arrive as HTTP 200 and a status-only classifier marks it VALID —
then the bot trades on a dead session. Fyers similarly carries "s": "error" and a
negative code in the body.alert_fn replaces AmbiguousProbeError with a ConnectionError — and
the caller's "do not spend a login" branch, bound to AmbiguousProbeError, never
runs. A failing alert must not change the verdict.probe_fn. A bare requests.get raises
ConnectionError/Timeout instead of returning a status, which skips the retry
path entirely and turns a transient blip into a hard startup failure. probe_fn
owns the translation to (None, True).python -m unittest discover -s skills/token-lifecycle-live-probing/scripts.headless-broker-auth-patternsmulti-broker-rate-limit-handlingpaper-to-live-promotion-checklistsecrets-rotation-without-bot-downtimeWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub himanshuj16/algo-trading-skills --plugin algo-trading-broker-integration36 skills in this plugin
/alpaca-paper-live-key-separationUse when a bot connects to the Alpaca Trading API and must never cross paper keys with the live endpoint; pins the base URL per environment, checks the key prefix, probes /v2/account and requires an explicit ALLOW_LIVE_TRADING flag./api-key-least-privilege-audit-toolUse before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft./broker-account-margin-call-handlingUse when a bot trades a Reg T, portfolio or futures margin account and must act before the broker liquidates: tiered maintenance-margin warnings cross-checked against broker excess liquidity, initial-margin order gating and liquidity-aware de-leveraging.Other plugins' skills for the same job