setup-scenario
Discover recommended scenarios, build and validate a ScenarioConfiguration, and auto-fix resource permissions.
- License 许可
- MIT
- 最近更新
- 2026-10-28
- Stars
- ★ 3
- Forks
- 4
01 前言 Front Matter
- name
- setup-scenario
- description
- Discover recommended scenarios, build and validate a ScenarioConfiguration, and auto-fix resource permissions.
02 资源文件 20
- 参考文档prompts/analyst-common.md1.5 KB
- 参考文档prompts/cost-and-time.md1.6 KB
- 参考文档prompts/plan-adherence.md1.6 KB
- 参考文档prompts/quality-evidence.md1.4 KB
- 参考文档prompts/repeated-work.md1.4 KB
- 参考文档prompts/request-conflicts.md1011 B
- 参考文档prompts/scrub-audit.md1.3 KB
- 参考文档prompts/scrub.md1.4 KB
- 参考文档prompts/similar-session.md1.7 KB
- 参考文档prompts/skill-timeline.md1.6 KB
- 参考文档prompts/stumbles.md1.3 KB
- 参考文档references/context-safety.md990 B
- 参考文档references/github-issues.md1.6 KB
- 参考文档references/redaction-policy.md2.2 KB
- 参考文档references/session-discovery.md1.8 KB
- 脚本scripts/Invoke-SetupScenario.ps112.8 KB
- 参考文档templates/bundle-README.md3.6 KB
- 参考文档templates/case.md2.9 KB
- 参考文档templates/issue.md1.8 KB
- 参考文档templates/report.md2.3 KB
03 SKILL.md 正文
SetupScenario — Scenario Discovery, Configuration & Validation
⛔ ABSOLUTE RULE: Do NOT improvise, skip, or substitute any step. On ANY error, STOP and wait for the user.
When to use this skill (vs. the MCP server)
This skill is the human-interactive path: it shares state with the rest of the pipeline, prompts via exit codes, and renders cards. Use it when there is a user in the loop.
If you are an autonomous agent with no user to prompt, use the MCP tools directly: chaos_refresh_recommendations, chaos_list_recommended_scenarios, chaos_create_scenario_configuration, chaos_validate_scenario_configuration, chaos_fix_resource_permissions. See mcp/README.md.
Both surfaces target Microsoft.Chaos 2026-05-01-preview and use the local az login session for auth.
How It Works
All discovery, configuration, validation, and permission-fix logic lives in scripts/Invoke-SetupScenario.ps1. The script drives the Chaos Studio operations through the az chaos CLI extension — workspace evaluation, recommendation listing, scenario selection routing, parameter resolution, configuration creation, and the validate→fix→re-validate loop.
The AI orchestrator's only job is:
- Set
$env:STARTCHAOS_STATE_PATHto${SESSION_DIR}/startchaos-state.json. - Run the script (no parameters needed for the first call).
- Handle exit codes that require user input (see below).
- Re-run the script with the user's answers as parameters.
Prerequisites
state.workspace.status == "done"(workspace must exist; the script refuses otherwise)state.context.subscriptionIdpopulated
Running the Script
$env:STARTCHAOS_STATE_PATH = "<session-dir>/startchaos-state.json"
& "<skill-dir>/scripts/Invoke-SetupScenario.ps1" @args
On resume: re-runs short-circuit when state.setup.status == "done".
Exit Codes → AI Actions
| Exit | Meaning | AI Action |
|---|---|---|
| 0 | Configuration created and validated | Done — summary already rendered by script. |
| 1 | Hard error | STOP. Render the error from script output. Wait for user. State has setup.lastError. |
| 2 | Scenario selection needed | Read state.setup.recommendedScenarios (or the script's rendered list). ask_user for one name. Re-run with -ScenarioName <chosen>. |
| 3 | Parameter mode needed | Show the parameter table from the script output. ask_user which parameters they want to override (or accept defaults). Re-run with -ParameterMode autofill and -ParameterValues @{ key = 'value' } for any overrides. |
Important: Manual mode does NOT work
-ParameterMode manual uses Read-Host prompts that do not render in a non-interactive AI session. Always use -ParameterMode autofill combined with -ParameterValues for any overrides the user requests.
Important: Exit 2 → 3 chaining
When exit 2 is followed by exit 3 on re-run, combine both answers in the next invocation:
& Invoke-SetupScenario.ps1 -ScenarioName "ZoneDown-1.0" -ParameterMode "autofill" -ParameterValues @{ duration = 'PT5M' }
Script Parameters
| Parameter | Description |
|---|---|
-ScenarioName |
Selected scenario (e.g. ZoneDown-1.0). Bypasses the selection prompt. Equivalent to $env:STARTCHAOS_SCENARIO. |
-ParameterMode |
autofill (always use this — manual does not work in AI sessions). |
-ParameterValues |
Hashtable of parameter overrides applied on top of defaults, e.g. @{ duration = 'PT5M' }. |
What the Script Handles (no AI logic needed)
- Workspace evaluation via
az chaos workspace refresh-recommendation(CLI awaits the LRO) +show-evaluationsummary - Scenario list (
az chaos scenario list) filtered torecommendation.recommendationStatus == "Recommended" - Auto-select when exactly one scenario is recommended; pause-and-emit-exit-2 otherwise
- ScenarioConfiguration create (
az chaos scenario config create,--scenario-idauto-derived) with parameter merge (defaults + overrides) - Validate (
az chaos scenario config validate) → if not Succeeded →az chaos scenario config fix-permissions→ re-validate - RBAC propagation retry loop (up to 5 minutes, 20s interval) gated to permission-related errors only
- Atomic state writes with error envelopes
- Idempotent re-runs
Related Skills
create-workspace— must complete before this skillrun-scenario— next phase after setup
04 同仓库更多 Skills
start-chaos
Orchestrate the full Chaos Studio v2 workflow: auth → workspace → scenario → run. Shares a single state file and supports resume.
run-scenario
Execute a ScenarioConfiguration and stream ScenarioRun status with per-action breakdown until terminal state.
create-workspace
Provision a Microsoft.Chaos/workspaces resource (v2), bind a managed identity, set scopes, and grant Reader RBAC on the scope.
chaos-study
Guided help for running a Chaos Studio study against an Azure workspace scope: frame a steady-state question with you, discover live which actions Chaos Studio offers for that region, freeze a plan, run a validated scenario configuration only with your explicit consent, collect the before/during/after signals you chose, and write a self-contained HTML report for your review. Start here for questions like 'what happens to my service when X?' or 'is my service resilient to X?'.
chaos-study-scope
Frame a Chaos study before anything runs: resolve or create a Chaos Studio V2 workspace, read the resources the service discovered inside its scopes, discover live which actions and scenarios are available for that region, express a falsifiable steady-state predicate, verify the action fits what is in scope, then freeze and hash the study plan.
chaos-study-run
Execute a frozen Chaos study plan against Azure using Chaos Studio V2: verify plan integrity, create and validate a scenario configuration, require an explicit typed consent phrase, collect baseline evidence, execute the scenario run, collect during and post-recovery evidence, and always clean up the configuration. Dry-run by default.