用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tradingstrategy-ai/trade-executor --skill create-test-from-prod命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | create-test-from-prod |
| description | Download state from a running trade executor and scaffold an acceptance test case |
Download the state file from a running trade-executor instance and scaffold a pytest acceptance test module.
https://executor.example.com)my_new_test); will be normalised to snake_case and any leading test_ prefix is stripped for the directory nameRun these two curl commands to gather information about the running executor:
curl -s <url>/metadata | python -m json.tool
curl -s <url>/source
From the /metadata JSON response, extract:
name — strategy name (used in the test module docstring)on_chain_data.chain_id — blockchain chain ID; map to the appropriate environment variable name:
1 → JSON_RPC_ETHEREUM137 → JSON_RPC_POLYGON8453 → JSON_RPC_BASE42161 → JSON_RPC_ARBITRUM56 → JSON_RPC_BNB43114 → JSON_RPC_AVALANCHEon_chain_data.asset_management_mode — one of enzyme, hot_wallet, lagoon, etc.on_chain_data (include whichever are present):
vault → VAULT_ADDRESSgeneric_adapter → VAULT_ADAPTER_ADDRESSpayment_forwarder → VAULT_PAYMENT_FORWARDER_ADDRESSdeployment_block → VAULT_DEPLOYMENT_BLOCK_NUMBERCompare the source code from /source against local strategy files:
strategies/ and strategies/test_only/AskUserQuestion and ask them to select the correct one or provide a pathRecord whether the strategy is in strategies/ or strategies/test_only/ and its filename.
mkdir -p tests/mainnet_fork/<test_case_name>
curl -s <url>/state -o tests/mainnet_fork/<test_case_name>/state.json
Verify the download succeeded and the file is non-empty.
Create tests/mainnet_fork/<test_case_name>/test_<test_case_name>.py using the template below.
Fill all <PLACEHOLDER> values from the metadata and strategy identification steps. Only include vault-specific environment variables that are actually present in the metadata.
"""<Strategy name> acceptance test.
- Does <Chain name> mainnet fork
- Archive node needed
- State file downloaded from <url>
"""
import os.path
import secrets
from pathlib import Path
from unittest import mock
import pytest
from _pytest.fixtures import FixtureRequest
from eth_defi.provider.anvil import AnvilLaunch, launch_anvil
from tradeexecutor.cli.commands.app import app
from tradeexecutor.utils.hex import hexbytes_to_hex_str
pytestmark = pytest.mark.skipif(
not os.environ.get("<JSON_RPC_CHAIN>") or not os.environ.get("TRADING_STRATEGY_API_KEY"),
reason="Set <JSON_RPC_CHAIN> and TRADING_STRATEGY_API_KEY environment variables to run this test",
)
@pytest.fixture()
def anvil(request: FixtureRequest) -> AnvilLaunch:
"""Do <Chain name> mainnet fork."""
mainnet_rpc = os.environ["<JSON_RPC_CHAIN>"]
anvil = launch_anvil(mainnet_rpc)
try:
yield anvil
finally:
anvil.close()
@pytest.fixture()
def state_file() -> Path:
"""State file downloaded from production."""
p = Path(os.path.join(os.path.dirname(__file__), "state.json"))
assert p.exists(), f"{p} missing"
return p
@pytest.fixture()
() -> Path:
p = Path(os.path.join(
os.path.dirname(__file__), , , ,
, , ,
))
p.exists(),
p
() -> :
environment = {
: strategy_file.as_posix(),
: hexbytes_to_hex_str(secrets.token_bytes()),
: anvil.json_rpc_url,
: state_file.as_posix(),
: ,
: ,
: ,
: ,
: os.environ[],
: ,
: (persistent_test_client.transport.cache_path),
}
environment
<test_case_name>(environment: ):
If the metadata contains vault addresses, add them to the environment fixture dict. Common patterns:
Enzyme vaults (asset_management_mode: enzyme):
"VAULT_ADDRESS": "<vault>",
"VAULT_ADAPTER_ADDRESS": "<generic_adapter>",
"VAULT_PAYMENT_FORWARDER_ADDRESS": "<payment_forwarder>",
"VAULT_DEPLOYMENT_BLOCK_NUMBER": "<deployment_block>",
Lagoon vaults (asset_management_mode: lagoon):
"VAULT_ADDRESS": "<vault>",
"VAULT_ADAPTER_ADDRESS": "<generic_adapter>",
For other asset management modes, include whatever vault-related fields are present in on_chain_data.
tests/mainnet_fork/test_correct_interest_not_accrued.py, tests/mainnet_fork/test_correct_accouting_closed_position_has_ausdc.pytradeexecutor/webhook/api.py (routes: /state, /metadata, /source)persistent_test_client fixture: tests/conftest.pystrategies/ and strategies/test_only/persistent_test_client fixture is defined in tests/conftest.py and is available to all tests automaticallypass — the user will fill in the actual test logicstrategies/ (not test_only/), adjust the relative path in the strategy_file fixture accordingly (remove the test_only segment)