skills/implementing-agent-modes/SKILL.md
Use this skill when adding mode-aware behavior to an AI agent, including explicit triggers, permissions, response contracts, and plan, ask, debug, or execute style interaction modes.
npx skillsauth add chatandbuild/chatchat-skills Implementing Agent ModesInstall 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.
Design and implement explicit agent modes so behavior is predictable, safe, and testable.
For each mode, define:
State machine for mode transitions. Model modes as states and transitions as edges. Each transition has a trigger (user command, explicit button, timeout) and optional guard (e.g., "only if user confirmed"). Invalid transitions return an error or prompt for clarification. Document the state machine as a table: Current Mode x Requested Mode -> Allowed (Y/N) + Action.
Permission matrix implementation. Maintain a matrix: Mode x Action Type (read_file, write_file, run_command, call_api) -> Allowed. Check this matrix before every tool invocation. Reject with a clear message ("Execute mode required for file writes") when the action is disallowed. Log blocked attempts for drift detection.
Confirmation dialogs for mode escalation. When transitioning from a lower-risk mode (ask, plan) to a higher-risk mode (execute), require explicit user confirmation. Present a summary of planned actions and a single "Proceed" or "Cancel" choice. Do not auto-escalate based on inferred intent.
Scenario scripts. Write scripts that simulate user flows: "User in ask mode requests file edit" -> expect blocked. "User in plan mode requests execution" -> expect confirmation prompt. "User confirms" -> expect execution. Run these as automated tests.
Boundary testing between modes. Test transitions at boundaries: first message in a session, mode switch mid-conversation, rapid successive mode changes. Ensure no state leakage (e.g., execute permissions carrying over after switch to ask).
Permission drift detection. Add regression tests that assert the permission matrix. When a new tool or action type is added, the test suite must explicitly allow or deny it per mode. Fail the build if an action is invoked in a mode where it is not explicitly permitted.
Implicit mode changes from context. Do not infer mode from phrasing like "go ahead" or "fix it" without explicit mode keywords or UI actions. Treat ambiguous requests as staying in the current mode or prompting for clarification.
Modes with overlapping permissions. If plan and execute both allow file reads, ensure they differ clearly on writes. Overlapping semantics cause inconsistent behavior when users expect one mode but get another.
No fallback for ambiguous intent. When the user's intent is unclear, default to the safest mode (ask or plan). Never default to execute. Provide a short disambiguation prompt: "Did you want me to (a) plan the changes or (b) execute them?"
Testing only happy paths. Include failure cases: tool errors, timeouts, user cancel, invalid transitions. Verify that the agent degrades gracefully and does not silently fall back to execute.
Return a structured specification:
## Mode Matrix
| Mode | read | write | execute | external | confirmation |
|--------|------|-------|---------|----------|--------------|
| ask | Y | N | N | N | - |
| plan | Y | N | N | N | - |
| debug | Y | N | N | Y (read) | - |
| execute| Y | Y | Y | Y | before first write |
## Transition Graph
| From | To | Trigger | Guard |
|--------|---------|----------------|--------------------|
| ask | plan | "plan" keyword | - |
| plan | execute | "execute" + UI | user confirmation |
| execute| ask | "stop" keyword | cancel pending |
## Safety Controls
- Confirmation points: <list>
- Blocked action handling: <message and log>
- Ambiguous intent: <default mode + prompt>
## Test Scenarios
- Scenario 1: <setup> -> <action> -> <expected outcome>
- Scenario 2: <setup> -> <action> -> <expected outcome>
- Boundary: <edge case> -> <expected outcome>
tools
Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).
development
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
development
Use this skill when turning messy workout information into clear logs, comparing user-provided sessions, surfacing trends or likely PRs, and suggesting realistic next-session steps.
tools
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.