/SKILL.md
Pre-trade risk assessment and policy enforcement for crypto trading using the Survivability-Aware Execution (SAE) framework. Use this skill before executing any crypto trade, when evaluating trader behavioral state (revenge trading, tilt, overconfidence, late-night impulsivity), when assessing market narrative risk, when computing position/leverage/frequency limits, when enforcing cool-down periods or staged execution, when auditing trading plugins or extensions for supply-chain risk, or when the user mentions risk management, survivability, blow-up prevention, liquidation avoidance, or trading discipline.
npx skillsauth add satoshirenz/sae-policy-guard sae-policy-guardInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Survivability-Aware Execution is a trading execution gate: before an order is placed, determine the maximum allowed risk budget and executable action set right now.
Core objective: minimize tail losses and liquidation probability — not maximize per-trade returns. Three modules: Trader-State Model, Market/Narrative Context, Policy Gate.
| Task | Action | Script |
|---|---|---|
| Pre-trade risk check | Run full SAE pipeline | trader_state.py → market_context.py → policy_gate.py |
| Behavioral state only | Score trader patterns | python scripts/trader_state.py --trades <file> |
| Market context only | Assess environment | python scripts/market_context.py --market <file> |
| Compute constraints | Generate policy gate | python scripts/policy_gate.py --trader-state <json> --market-context <json> |
| Narrative firewall | Check narrative risk | python scripts/market_context.py --market <file> --mode narrative |
| Plugin/extension audit | Scan supply-chain risk | python scripts/threat_audit.py --target <path> |
| Replay evaluation | Backtest SAE decisions | python scripts/replay_evaluate.py --trades <file> |
| Full threat assessment | Run threat model | Follow threat assessment workflow below |
Follow these 8 steps for every trade assessment. Do NOT skip steps.
Collect from the user:
If no explicit trade, assess current state for monitoring. If user cannot provide trade history, use self-reported state with conservative defaults.
Run scripts/trader_state.py with the trader's recent trade history.
Input format — JSON array of trades:
[
{
"timestamp": "2026-02-19T14:30:00Z",
"asset": "BTC-PERP",
"direction": "long",
"size_usd": 5000,
"leverage": 10,
"pnl_usd": -450,
"holding_minutes": 12,
"was_stop_loss": false
}
]
Output — JSON with scores (0.0–1.0) for six patterns:
revenge_trading: loss → rapid re-entry with increased sizeoverconfidence: win streak → size escalationhigh_freq_switching: excessive direction/asset changeslate_night_impulsivity: trades outside normal hourstilt_averaging: adding to losing positions repeatedlyfomo_chasing: entering after large price movesPlus composite risk_escalation_probability (0.0–1.0).
If trade history is unavailable, ask the user about recent losses, current emotional state, time of day, and how many trades they have made today. Apply conservative defaults (risk_escalation_probability >= 0.5 when uncertain).
Run scripts/market_context.py with current market data.
Input format — JSON:
{
"asset": "BTC-PERP",
"candles_1h": [{"timestamp": "...", "open": 97000, "high": 97500, "low": 96800, "close": 97200, "volume": 1234567}],
"funding_rate": 0.0003,
"open_interest_usd": 15000000000,
"orderbook_depth_bps_10": 5000000,
"spread_bps": 1.2
}
Optional sentiment input:
{
"social_volume_24h": 45000,
"social_volume_7d_avg": 12000,
"sentiment_score": 0.82,
"top_keywords": ["moon", "breakout", "ATH"]
}
Output — volatility_regime, liquidity_score, event_window, narrative_intensity, error_amplification_score.
If market data is unavailable, ask the user to describe current conditions or default to elevated caution (error_amplification_score = 0.5).
Run scripts/policy_gate.py combining outputs from Steps 2 and 3, plus trade intent.
The script applies the Policy Matrix and outputs enforceable constraints:
gate_decision: ALLOW / CONSTRAIN / COOL_DOWN / BLOCKmax_position_pct: max position as % of portfoliomax_leverage: max allowed leveragemax_trades_per_hour: frequency budgetcool_down_minutes: mandatory wait (0 if none)staged_execution: whether order must be split into tranchesstage_count: number of tranches if stagednarrative_exclusion: whether narrative firewall blocks this tradepolicy_token_required: whether forced confirmation is neededviolations: list of specific constraint breachesrationale: human-readable explanationFormat output using assets/policy-report-template.md. Clearly show:
For each decision type:
If policy_token_required is true:
CRITICAL: A BLOCK decision cannot be overridden. Only CONSTRAIN and COOL_DOWN support policy tokens.
After execution or non-execution, log:
trade_id, sae_decision, constraints_applied, override_used, actual_outcomeThis data feeds back into Step 2 for future assessments. Recommend the user maintain a local trade journal JSON file for continuous improvement.
On request or at regular intervals, run scripts/replay_evaluate.py to assess SAE
effectiveness. Report: tail-risk reduction, false-block rate, lead time.
See references/evaluation-protocol.md for methodology.
The policy gate maps (trader_risk_band × market_risk_band) to constraints:
| Trader Risk | Market Risk | Decision | Position Cap | Leverage Cap | Cool-Down | Staged | Narrative Block | |---|---|---|---|---|---|---|---| | Low (<0.3) | Low (<0.3) | ALLOW | 100% | 100% | 0 min | No | No | | Low | Medium (0.3–0.6) | CONSTRAIN | 75% | 75% | 0 min | No | No | | Low | High (>0.6) | CONSTRAIN | 50% | 50% | 0 min | 2 tranches | If narrative >0.8 | | Medium (0.3–0.6) | Low | CONSTRAIN | 75% | 75% | 0 min | No | No | | Medium | Medium | CONSTRAIN | 50% | 50% | 15 min | 2 tranches | If narrative >0.7 | | Medium | High | COOL_DOWN | 25% | 25% | 30 min | 3 tranches | If narrative >0.6 | | High (>0.6) | Low | CONSTRAIN | 50% | 50% | 15 min | 2 tranches | No | | High | Medium | COOL_DOWN | 25% | 25% | 30 min | 3 tranches | If narrative >0.5 | | High | High | BLOCK | 0% | 0% | 60 min | N/A | Yes |
All thresholds configurable via assets/config-schema.yaml.
The narrative firewall predicts whether current market narrative will trigger loss-of-control behavior — NOT whether price will move.
Signals:
When narrative_exclusion triggers:
--mode narrative for standalone narrative assessmentFor auditing trading system plugins, bots, or extensions:
python scripts/threat_audit.py --target <plugin-path>assets/threat-assessment-template.mdreferences/threat-model.md for the full taxonomyAll thresholds are configurable. Copy assets/config-schema.yaml, modify values,
and pass with --config <path> to any script.
Key configurable parameters:
These are not suggestions. They are constraints.
gate_decision is BLOCK: the agent MUST refuse to execute the trade. No exceptions. No overrides.gate_decision is COOL_DOWN: the agent MUST impose the actual time delay. No early release.gate_decision is CONSTRAIN: the agent MUST adjust trade parameters to fit constraints before execution.policy_token_required is true: the agent MUST obtain explicit user confirmation before proceeding.tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.