core/capabilities/orchestration/flag-parser/SKILL.md
Parses workflow flags (--quality-locked, --autonomous) from $ARGUMENTS at the start of /build and /architect commands. Uses deterministic runtimes (Python primary, Bash fallback) with prose-rule fallback if neither runtime is available. Returns a strict JSON contract that the agent trusts unconditionally.
npx skillsauth add xoai/sage flag-parserInstall 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.
Workflow flags are passed inline in slash command arguments. Both
/build and /architect accept the same flags, parsed identically.
Parsing must be deterministic. Prose-only parsing by the agent is unreliable — the runtime layers below produce the same JSON output and the agent trusts that JSON unconditionally.
| Flag | Effect | Default |
|------|--------|---------|
| --quality-locked | Loop review/revise until findings are clean or cap (10) hit | off (overridable by config) |
| --no-quality-locked | Force off, overriding a config default | — |
| --autonomous | Agent makes elicitation decisions from memory/codebase/principles | off (overridable by config) |
| --no-autonomous | Force off, overriding a config default | — |
For each mode (quality_locked, autonomous):
| Priority | Source | Effect | Source label |
|----------|--------|--------|--------------|
| 1 (highest) | --no-<flag> | Force off | "flag" |
| 2 | --<flag> | Force on | "flag" |
| 3 | <flag>: true in .sage/config.yaml | Default on | "config" |
| 4 (lowest) | nothing | Off (current behavior) | null |
Flag vs config when they agree: the source label is "flag"
(explicit intent always labels, even when the value matches config).
Functional outcome is the same (mode on).
Conflict: passing --<flag> AND --no-<flag> in the same invocation
is a user error. The parser returns an error JSON and exits non-zero.
Read from .sage/config.yaml. Strict-match contract: only lines
matching exactly <key>: true (with one space after the colon,
lowercase true, no trailing characters) are honored. The strict form
ensures Python and Bash agree byte-for-byte. Rejected variants
(treated as no default):
quality_locked: True (titlecase)quality_locked: "true" (quoted)quality_locked: yes (YAML alias)quality_locked:true (no space)quality_locked: true (extra space)quality_locked: true # comment (trailing content)quality_locked: false is equivalent to no default — value is off.
Use the --quality-locked flag to override.
All three parsing layers emit the same JSON shape to stdout:
{
"quality_locked": true | false,
"autonomous": true | false,
"goal": "<remainder after flags, trimmed>",
"error": null | "<error message>",
"quality_locked_source": "flag" | "config" | null,
"autonomous_source": "flag" | "config" | null
}
Source value is "flag" whenever a flag (positive --X or negative
--no-X) influenced the result. "config" only when no flag was
passed AND config provides the default-on. null when the value is
the implicit default-off.
Exit code semantics:
0 — clean parse (error: null)1 — unknown flag, conflicting flags, or malformed input
(error is populated; JSON still printed)The agent tries each layer in order. As soon as one returns valid JSON, use it and skip the rest.
python -m core.flag_parser parse "$ARGUMENTS" --config-path .sage/config.yaml
The --config-path is optional — when provided, the parser reads
quality_locked: true / autonomous: true lines as defaults. When
omitted (or the file is missing/malformed), no defaults apply.
Outputs JSON to stdout. Exit 0 on clean parse, 1 on unknown flag or conflict.
bash sage/core/flag_parser/parse.sh "$ARGUMENTS" --config-path .sage/config.yaml
Same JSON shape, same exit codes. Uses only POSIX bash features — works on macOS bash 3.2+ and any Linux bash.
Use ONLY when both Python and Bash are unavailable (rare — locked-down container, embedded environments). The agent reads the parsing rules below and produces JSON manually.
Announce when falling back:
Sage: Deterministic parsers unavailable (Python and Bash both failed).
Using prose-rule fallback for flag parsing.
This is the only case where prose parsing is acceptable.
--autonomous --quality-locked and
--quality-locked --autonomous are equivalent.-- and
the flag name isn't recognized, return JSON with error populated.--quality-locked=true is not supported.INPUT: "Ship dark mode"
OUTPUT: {"quality_locked": false, "autonomous": false, "goal": "Ship dark mode", "error": null}
INPUT: "--quality-locked Ship dark mode"
OUTPUT: {"quality_locked": true, "autonomous": false, "goal": "Ship dark mode", "error": null}
INPUT: "--autonomous --quality-locked Ship dark mode"
OUTPUT: {"quality_locked": true, "autonomous": true, "goal": "Ship dark mode", "error": null}
INPUT: "--quality-locked"
OUTPUT: {"quality_locked": true, "autonomous": false, "goal": "", "error": null}
INPUT: "Ship --quality-locked dark mode" # flag not at start
OUTPUT: {"quality_locked": false, "autonomous": false, "goal": "Ship --quality-locked dark mode", "error": null}
INPUT: "--foo bar"
OUTPUT: {"quality_locked": false, "autonomous": false, "goal": "", "error": "Unknown flag '--foo'. Supported flags: --quality-locked, --autonomous."}
EXIT: 1
quality_locked and autonomous booleans for the rest of the
workflow.goal as the user's task description (may be empty — workflow
will auto-pickup from .sage/work/).Sage → build workflow.
Modes: --quality-locked, --autonomous
Goal: Ship dark mode for the dashboard
If both flags are false, omit the Modes line entirely.
Surface the error verbatim to the user and stop the workflow:
Sage: {error message}
Do NOT guess what the user meant. Wait for them to retry with the correct flag name.
After successful parsing, before starting Step 1, the workflow writes flag state to manifest.md frontmatter:
flags:
quality_locked: true
autonomous: true
On /continue, the workflow reads these fields and restores both
modes for the duration of the session.
| Situation | Behavior |
|---|---|
| Python missing | Fall through to Bash layer automatically |
| Bash failed (e.g., parse.sh missing) | Fall through to prose-rule layer |
| Unknown flag | Surface error message, stop workflow |
| Empty $ARGUMENTS | Both modes off, empty goal — workflow may scan .sage/work/ for active initiative |
| /continue overrides | New invocation's flags override manifest; note to user |
tools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).
development
Typed knowledge graph stored in sage-memory. Use when creating or querying structured entities (Person, Project, Task, Event, Document), linking related objects, checking dependencies, planning multi-step actions as graph transformations, or when skills need to share structured state. Trigger on "remember that X is Y", "what do I know about", "link X to Y", "show dependencies", "what blocks X", entity CRUD, cross-skill data access, or any request involving structured relationships between things.
tools
Integrates sage-memory into Sage workflows. Teaches the agent when to remember (store findings during work), when to recall (search memory at session start and task start), and how to learn (structured knowledge capture via sage learn). Use when the user mentions memory, remember, recall, learn, capture knowledge, onboard to codebase, or when starting any session where sage-memory MCP tools are available.
tools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).