[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6K20WYT5GG6XF1R3Q5XBB8H":3,"skill-same:01M6K20WYT5GG6XF1R3Q5XBB8H":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M6K20WYT5GG6XF1R3Q5XBB8H","cli-flag-review",null,"Audit and optimize CLI flag definitions across all skeptic subcommands. Reviews help text quality, global-vs-local flag modeling, short flag coverage, shorthand config-precedence safety, help formatter consistency, and test isolation. Use when adding flags, reviewing CLI ergonomics, refactoring subcommand interfaces, or debugging flag override behavior.","TGPSKI\u002Fskeptic","TGPSKI","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F12532803?v=4","01M6K20PYXDJ1HVD04MF5W8W09","Tyler Pate","01M6K20Q2S3W3JSXJZRF0C91S3",2,"GPL-3.0","https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcli-flag-review\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"cli","cli flag review","review","flags","formatter","reviews","ergonomics","modeling","local","across","optimize","config","skeptic","coverage","short","text","refactoring","Safety","audit","debugging","2026-11-10 10:12:30",false,"---\nname: cli-flag-review\ndescription: >-\n  Audit and optimize CLI flag definitions across all skeptic subcommands.\n  Reviews help text quality, global-vs-local flag modeling, short flag\n  coverage, shorthand config-precedence safety, help formatter consistency,\n  and test isolation. Use when adding flags, reviewing CLI ergonomics,\n  refactoring subcommand interfaces, or debugging flag override behavior.\n---\n\n# CLI Flag Review\n\nSystematic audit of every CLI flag in skeptic. Covers help text, short aliases,\nglobal passthrough decisions, config-precedence safety, help output formatting,\ntest isolation, and implementation correctness.\n\n## Workflow\n\n1. **Inventory** — collect every `fs.*Var` registration across `cmd\u002Fskeptic\u002F` and `internal\u002F` subcommand entry points.\n2. **Help text audit** — apply the quality rules below to every help string.\n3. **Short flag audit** — assign single-letter aliases per the priority table.\n4. **Shorthand precedence audit** — verify every shorthand is registered in the config-layer maps (see below).\n5. **Help formatter audit** — verify `printScanFlags` and `scanFlagShorthands` are in sync with registrations.\n   Verify every subcommand usage function calls `config.PrintSubcommandHeader`\n   with a one-line synopsis and at least one worked example.\n6. **Global vs local audit** — decide whether each flag should be global (pre-parsed in `extractGlobalFlags`) or local to its subcommand `FlagSet`.\n7. **Test isolation audit** — verify every test calling `run()` or `ResolveConfigLayers()` sets `XDG_DATA_HOME`.\n8. **Implement** — edit flag registrations, update maps, run `go fmt && go vet && go test -race .\u002F...`.\n\n## Help Text Quality Rules\n\nEach help string must:\n\n- Start lowercase (Go `flag` convention)\n- Be a noun phrase or imperative verb phrase, not a sentence\n- State the **effect**, not just the name (bad: `\"output format\"`, good: `\"output format: json|text|sarif|markdown\"`)\n- List allowed values inline when the set is small (≤6 values)\n- Include the unit for numeric flags (`\"bytes\"`, `\"seconds\"`, `\"goroutines\"`)\n- State the zero-value behavior when non-obvious (`\"0 = auto\"`, `\"empty = auto-discover\"`)\n- Not exceed ~90 characters\n- Not duplicate the flag name verbatim as the first word\n- Use **identical** help text for both the short and long registration (no `(shorthand)` suffix — the custom help formatter merges them)\n\n### Examples\n\n```\nBAD:  \"path\"                          → just restates the flag name\nGOOD: \"file or directory to scan\"\n\nBAD:  \"Output format\"                 → capitalized, no values listed\nGOOD: \"output format: text|json|sarif|markdown\"\n\nBAD:  \"workers\"                       → no unit or zero-value note\nGOOD: \"parallel scan goroutines (0 = NumCPU)\"\n```\n\n## Short Flag Assignment\n\n### Priority tiers\n\nAssign short flags to the **most frequently typed** options first. A flag\nqualifies for a short alias when it is used interactively (not just in config\nfiles or CI scripts).\n\n| Tier | Criteria | Examples |\n|------|----------|---------|\n| 1 — always | Every subcommand that has it | `-v` verbose, `-q` quiet, `-c` config |\n| 2 — high | Primary I\u002FO flags | `-o` out, `-f` format, `-p` path |\n| 3 — medium | Commonly toggled behavior | `-r` rules-dir, `-s` source, `-n` dry-run |\n| 4 — skip | Rarely typed or dangerous | `--require-signed-rules`, `--xor-brute` |\n\n### Letter reservation\n\nThese letters are reserved project-wide to avoid collisions:\n\n| Letter | Reserved for |\n|--------|-------------|\n| `-v` | `--verbose` (global) |\n| `-q` | `--quiet` (global) |\n| `-c` | `--config` (global) |\n| `-o` | `--out` |\n| `-f` | `--format` |\n| `-p` | `--path` |\n| `-r` | `--rules-dir` or `--rules-file` |\n| `-s` | `--source` |\n| `-n` | `--dry-run` or `--name` |\n| `-t` | `--timeout` variants |\n| `-m` | `--max-*` variants |\n| `-e` | `--expected-rules` or `--ecosystems` |\n| `-H` | `--allow-host` |\n| `-M` | `--metadata` |\n| `-y` | `--confirm` |\n\nA short flag must not collide with another short flag **on the same FlagSet**.\nDifferent subcommands may reuse the same letter for different flags if the\nsemantics are analogous (e.g. `-o` always means output path).\n\n### Registration pattern\n\nAlways register the short form as a separate `fs.*Var` pointing to the same\nvariable, immediately after the long form. Use identical help text for both:\n\n```go\nfs.StringVar(&outPath, \"out\", \"\", \"write report to file\")\nfs.StringVar(&outPath, \"o\", \"\", \"write report to file\")\n```\n\nDo **not** add a `(shorthand)` suffix — the custom help formatter (`printScanFlags`)\nmerges both onto one line automatically.\n\n## Shorthand Config-Precedence Safety\n\n**This is the most common source of CLI flag bugs.** Go's `flag.Visit` records\nthe `Flag.Name` that was parsed, not aliases. When a user passes `-f json`,\nthe visited set contains `\"f\"`, not `\"format\"`. If `ApplyRunConfigValues` only\nchecks `FlagWasSet(visited, \"format\")`, it sees `format` as unset and allows\nconfig\u002Fpreset\u002Fprofile layers to silently overwrite the user's explicit choice.\n\n### Three synchronization points\n\nAdding or removing a shorthand requires updates in **three** places:\n\n| Location | Map | Direction | Purpose |\n|----------|-----|-----------|---------|\n| `internal\u002Fconfig\u002Fconfig.go` `ApplyRunConfigValues` | `flagShorthands` | canonical → short (`\"format\": \"f\"`) | Config-layer precedence: prevents config\u002Fpreset\u002Fprofile from overwriting CLI shorthand values |\n| `cmd\u002Fskeptic\u002Fmain.go` | `scanFlagShorthands` | short → canonical (`\"f\": \"format\"`) | Help formatter: merges `-f` and `--format` onto one line, suppresses standalone shorthand entry |\n| `cmd\u002Fskeptic\u002Fperform_skeptic_run.go` `registerRunFlags` | (the `fs.*Var` calls) | Both names registered | Actual flag registration with Go's `flag` package |\n\n**When adding a new shorthand**, update all three. When reviewing existing flags,\nverify all three are in sync.\n\n### How `ApplyRunConfigValues` uses the map\n\n```go\nflagShorthands := map[string]string{\n    \"format\": \"f\",\n    \"path\":   \"p\",\n}\n\nflagExplicit := func(flagName string) bool {\n    if FlagWasSet(visited, flagName) {\n        return true\n    }\n    if short, ok := flagShorthands[flagName]; ok {\n        return FlagWasSet(visited, short)\n    }\n    return false\n}\n```\n\nEvery `setString` \u002F `setBool` \u002F `setInt` \u002F `setFloat64` call in that function\nuses `flagExplicit(name)` instead of raw `FlagWasSet(visited, name)`.\n\n### Flags that also need shorthand checks in `ResolveConfigLayers`\n\n`--mode` and `--preset` are checked directly in `ResolveConfigLayers` (before\n`ApplyRunConfigValues` runs) with bare `FlagWasSet` calls. If shorthands are\never added for these flags, those call sites must also check the short name.\nBoth have inline comments flagging this.\n\n## Help Output Formatting\n\n### Custom formatter (`printScanFlags`)\n\nThe scan `--help` output uses `printScanFlags` (in `main.go`) instead of Go's\n`fs.PrintDefaults()`. This formatter:\n\n- Merges shorthand and long-form flags on one line (`-f, --format VALUE`)\n- Uses `--` prefix for all multi-char flags (POSIX convention)\n- Suppresses standalone shorthand entries (they appear merged)\n- Omits global flags already shown in the hand-written header section\n- Uses contextual type hints (`PATH`, `VALUE`, `N`, `GLOB`) via `flagTypeName`\u002F`inferStringMeta`\n\n### When to update the formatter\n\n- **Adding a shorthand**: add to `scanFlagShorthands` map\n- **Adding a path-like flag**: add its name to `inferStringMeta` so it gets `PATH` label\n- **Adding a glob-like flag**: add its name to `inferStringMeta` so it gets `GLOB` label\n- **Adding a new global flag**: add to the `globals` map inside `printScanFlags`\n\n### Manual verification\n\nAfter any flag change, build and check output visually:\n\n```bash\ngo build -o \u002Ftmp\u002Fskeptic-test .\u002Fcmd\u002Fskeptic\u002F\n\u002Ftmp\u002Fskeptic-test scan --help 2>&1 | head -80\nrm -f \u002Ftmp\u002Fskeptic-test\n```\n\nVerify: no duplicate entries, no single-dash long flags, shorthands merged,\ntype hints make sense, globals not repeated in scan section.\n\n## Global vs Local Decision\n\n### When a flag should be global\n\nA flag belongs in `extractGlobalFlags` (pre-parsed before subcommand dispatch)\nwhen **all** of these are true:\n\n1. It applies to **every** subcommand (or nearly every one).\n2. It controls **infrastructure** (logging, profiling, config loading), not scan behavior.\n3. It does not conflict with a subcommand-specific flag of the same name.\n\nCurrent globals: `--verbose\u002F-v`, `--quiet\u002F-q`, `--cpu-profile`, `--mem-profile`,\n`--trace`, `--perf-debug`, `--log-file`, `--config\u002F-c`.\n\n### When a flag should be local\n\nA flag is local when:\n\n- It only makes sense for one subcommand (e.g. `--bind` for `serve`).\n- It controls scan behavior that varies by context (e.g. `--scan-style`).\n- It has a subcommand-specific default (e.g. `--fail-on` defaults differ).\n\n### Passthrough patterns\n\n| Pattern | When to use | Example |\n|---------|-------------|---------|\n| Direct field access (`gf.Verbosity`) | Subcommand handler is in `cmd\u002Fskeptic\u002F` and receives `globalFlags` | corpus subcommands |\n| `mergeGlobalFlagsIntoArgs` | Subcommand parses its own `FlagSet` in `internal\u002F` and needs globals as argv | `ingest`, default scan |\n| Prepend `--config` only | Subcommand only needs config path from globals | `waive`, `serve`, `mcp` |\n| `globalProfileAndStop` only | Subcommand only needs profiling from globals | `bundle`, `export-evidence` |\n\nWhen adding a new subcommand, choose the **simplest** pattern that covers the\nglobals it needs. Do not merge all globals if only config is needed.\n\n## Test Isolation for Config-Loading Code\n\nAny test that calls `run()`, `performSkepticRun()`, or `ResolveConfigLayers()`\nexercises the config auto-discovery path: `LoadConfigValues` → `DiscoverConfigPath`\n→ `ActiveProfilePath`. If `XDG_DATA_HOME` is not isolated, the test picks up the\ndeveloper's real XDG profile (e.g. `~\u002F.local\u002Fshare\u002Fskeptic\u002Fprofiles\u002Fdev.json`),\nwhich can set `preset`, `format`, `waivers`, and other values that silently change\ntest behavior.\n\n### Required isolation\n\n```go\nfunc TestAnythingThatCallsRun(t *testing.T) {\n    t.Setenv(\"XDG_DATA_HOME\", t.TempDir())  \u002F\u002F FIRST LINE\n    \u002F\u002F ... rest of test\n}\n```\n\n### When isolation is required\n\n| Calls | Needs `XDG_DATA_HOME` isolation? |\n|-------|----------------------------------|\n| `run(...)` | **Yes** — always |\n| `performSkepticRun(...)` | **Yes** — always |\n| `ResolveConfigLayers(...)` | **Yes** — always |\n| `LoadConfigValues(...)` | **Yes** — always |\n| `DiscoverConfigPath()` | **Yes** — always |\n| `ActiveProfilePath()` \u002F `ActiveProfileName()` | **Yes** — always |\n| `LoadSystemConfig(\"\")` (empty path) | **Yes** — auto-discovers from XDG |\n| `LoadSystemConfig(\"\u002Fexplicit\u002Fpath\")` | No — explicit path bypasses discovery |\n| `ApplyRunConfigValues(...)` | No — pure value merge, no filesystem access |\n| `FlagWasSet(...)` \u002F `VisitedFlagNames(...)` | No — pure map lookups |\n| Validation-only tests (exit code 2 before config loads) | Technically safe but **still isolate** for robustness |\n\n### Audit checklist\n\nWhen reviewing tests:\n\n1. Search `cmd\u002Fskeptic\u002F*_test.go` and `internal\u002Fconfig\u002F*_test.go` for `run(`, `performSkepticRun(`, `ResolveConfigLayers(`\n2. Verify each match has `t.Setenv(\"XDG_DATA_HOME\", t.TempDir())` before the call\n3. If the test also uses `os.Chdir`, the `XDG_DATA_HOME` setenv must come **before** the chdir\n\n## Verification\n\nAfter any flag change:\n\n```bash\ngo fmt .\u002F...\ngo vet .\u002F...\ngo build .\u002F...\ngo test -race -count=1 .\u002Fcmd\u002Fskeptic\u002F .\u002Finternal\u002Fconfig\u002F .\u002Finternal\u002Fcorpus\u002F\n```\n\nCheck `--help` output for each modified subcommand to verify formatting.\n\n## Quick Checklist — Adding a New Shorthand\n\n- [ ] Register both `fs.*Var(&field, \"long-name\", ...)` and `fs.*Var(&field, \"x\", ...)` in `registerRunFlags`\n- [ ] Use identical help text for both (no `(shorthand)` suffix)\n- [ ] Add `\"long-name\": \"x\"` to `flagShorthands` in `ApplyRunConfigValues` (`internal\u002Fconfig\u002Fconfig.go`)\n- [ ] Add `\"x\": \"long-name\"` to `scanFlagShorthands` in `main.go`\n- [ ] If the flag is also checked directly in `ResolveConfigLayers`, update that call site\n- [ ] Add a test case to `TestApplyRunConfigValuesShorthandFlagPrecedence` verifying the shorthand blocks config override\n- [ ] Run `go test -race -count=1 .\u002Fcmd\u002Fskeptic\u002F .\u002Finternal\u002Fconfig\u002F`\n- [ ] Build and visually verify `--help` output shows merged `-x, --long-name` line\n","# CLI Flag Review\n\nSystematic audit of every CLI flag in skeptic. Covers help text, short aliases,\nglobal passthrough decisions, config-precedence safety, help output formatting,\ntest isolation, and implementation correctness.\n\n## Workflow\n\n1. **Inventory** — collect every `fs.*Var` registration across `cmd\u002Fskeptic\u002F` and `internal\u002F` subcommand entry points.\n2. **Help text audit** — apply the quality rules below to every help string.\n3. **Short flag audit** — assign single-letter aliases per the priority table.\n4. **Shorthand precedence audit** — verify every shorthand is registered in the config-layer maps (see below).\n5. **Help formatter audit** — verify `printScanFlags` and `scanFlagShorthands` are in sync with registrations.\n   Verify every subcommand usage function calls `config.PrintSubcommandHeader`\n   with a one-line synopsis and at least one worked example.\n6. **Global vs local audit** — decide whether each flag should be global (pre-parsed in `extractGlobalFlags`) or local to its subcommand `FlagSet`.\n7. **Test isolation audit** — verify every test calling `run()` or `ResolveConfigLayers()` sets `XDG_DATA_HOME`.\n8. **Implement** — edit flag registrations, update maps, run `go fmt && go vet && go test -race .\u002F...`.\n\n## Help Text Quality Rules\n\nEach help string must:\n\n- Start lowercase (Go `flag` convention)\n- Be a noun phrase or imperative verb phrase, not a sentence\n- State the **effect**, not just the name (bad: `\"output format\"`, good: `\"output format: json|text|sarif|markdown\"`)\n- List allowed values inline when the set is small (≤6 values)\n- Include the unit for numeric flags (`\"bytes\"`, `\"seconds\"`, `\"goroutines\"`)\n- State the zero-value behavior when non-obvious (`\"0 = auto\"`, `\"empty = auto-discover\"`)\n- Not exceed ~90 characters\n- Not duplicate the flag name verbatim as the first word\n- Use **identical** help text for both the short and long registration (no `(shorthand)` suffix — the custom help formatter merges them)\n\n### Examples\n\n```\nBAD:  \"path\"                          → just restates the flag name\nGOOD: \"file or directory to scan\"\n\nBAD:  \"Output format\"                 → capitalized, no values listed\nGOOD: \"output format: text|json|sarif|markdown\"\n\nBAD:  \"workers\"                       → no unit or zero-value note\nGOOD: \"parallel scan goroutines (0 = NumCPU)\"\n```\n\n## Short Flag Assignment\n\n### Priority tiers\n\nAssign short flags to the **most frequently typed** options first. A flag\nqualifies for a short alias when it is used interactively (not just in config\nfiles or CI scripts).\n\n| Tier | Criteria | Examples |\n|------|----------|---------|\n| 1 — always | Every subcommand that has it | `-v` verbose, `-q` quiet, `-c` config |\n| 2 — high | Primary I\u002FO flags | `-o` out, `-f` format, `-p` path |\n| 3 — medium | Commonly toggled behavior | `-r` rules-dir, `-s` source, `-n` dry-run |\n| 4 — skip | Rarely typed or dangerous | `--require-signed-rules`, `--xor-brute` |\n\n### Letter reservation\n\nThese letters are reserved project-wide to avoid collisions:\n\n| Letter | Reserved for |\n|--------|-------------|\n| `-v` | `--verbose` (global) |\n| `-q` | `--quiet` (global) |\n| `-c` | `--config` (global) |\n| `-o` | `--out` |\n| `-f` | `--format` |\n| `-p` | `--path` |\n| `-r` | `--rules-dir` or `--rules-file` |\n| `-s` | `--source` |\n| `-n` | `--dry-run` or `--name` |\n| `-t` | `--timeout` variants |\n| `-m` | `--max-*` variants |\n| `-e` | `--expected-rules` or `--ecosystems` |\n| `-H` | `--allow-host` |\n| `-M` | `--metadata` |\n| `-y` | `--confirm` |\n\nA short flag must not collide with another short flag **on the same FlagSet**.\nDifferent subcommands may reuse the same letter for different flags if the\nsemantics are analogous (e.g. `-o` always means output path).\n\n### Registration pattern\n\nAlways register the short form as a separate `fs.*Var` pointing to the same\nvariable, immediately after the long form. Use identical help text for both:\n\n```go\nfs.StringVar(&outPath, \"out\", \"\", \"write report to file\")\nfs.StringVar(&outPath, \"o\", \"\", \"write report to file\")\n```\n\nDo **not** add a `(shorthand)` suffix — the custom help formatter (`printScanFlags`)\nmerges both onto one line automatically.\n\n## Shorthand Config-Precedence Safety\n\n**This is the most common source of CLI flag bugs.** Go's `flag.Visit` records\nthe `Flag.Name` that was parsed, not aliases. When a user passes `-f json`,\nthe visited set contains `\"f\"`, not `\"format\"`. If `ApplyRunConfigValues` only\nchecks `FlagWasSet(visited, \"format\")`, it sees `format` as unset and allows\nconfig\u002Fpreset\u002Fprofile layers to silently overwrite the user's explicit choice.\n\n### Three synchronization points\n\nAdding or removing a shorthand requires updates in **three** places:\n\n| Location | Map | Direction | Purpose |\n|----------|-----|-----------|---------|\n| `internal\u002Fconfig\u002Fconfig.go` `ApplyRunConfigValues` | `flagShorthands` | canonical → short (`\"format\": \"f\"`) | Config-layer precedence: prevents config\u002Fpreset\u002Fprofile from overwriting CLI shorthand values |\n| `cmd\u002Fskeptic\u002Fmain.go` | `scanFlagShorthands` | short → canonical (`\"f\": \"format\"`) | Help formatter: merges `-f` and `--format` onto one line, suppresses standalone shorthand entry |\n| `cmd\u002Fskeptic\u002Fperform_skeptic_run.go` `registerRunFlags` | (the `fs.*Var` calls) | Both names registered | Actual flag registration with Go's `flag` package |\n\n**When adding a new shorthand**, update all three. When reviewing existing flags,\nverify all three are in sync.\n\n### How `ApplyRunConfigValues` uses the map\n\n```go\nflagShorthands := map[string]string{\n    \"format\": \"f\",\n    \"path\":   \"p\",\n}\n\nflagExplicit := func(flagName string) bool {\n    if FlagWasSet(visited, flagName) {\n        return true\n    }\n    if short, ok := flagShorthands[flagName]; ok {\n        return FlagWasSet(visited, short)\n    }\n    return false\n}\n```\n\nEvery `setString` \u002F `setBool` \u002F `setInt` \u002F `setFloat64` call in that function\nuses `flagExplicit(name)` instead of raw `FlagWasSet(visited, name)`.\n\n### Flags that also need shorthand checks in `ResolveConfigLayers`\n\n`--mode` and `--preset` are checked directly in `ResolveConfigLayers` (before\n`ApplyRunConfigValues` runs) with bare `FlagWasSet` calls. If shorthands are\never added for these flags, those call sites must also check the short name.\nBoth have inline comments flagging this.\n\n## Help Output Formatting\n\n### Custom formatter (`printScanFlags`)\n\nThe scan `--help` output uses `printScanFlags` (in `main.go`) instead of Go's\n`fs.PrintDefaults()`. This formatter:\n\n- Merges shorthand and long-form flags on one line (`-f, --format VALUE`)\n- Uses `--` prefix for all multi-char flags (POSIX convention)\n- Suppresses standalone shorthand entries (they appear merged)\n- Omits global flags already shown in the hand-written header section\n- Uses contextual type hints (`PATH`, `VALUE`, `N`, `GLOB`) via `flagTypeName`\u002F`inferStringMeta`\n\n### When to update the formatter\n\n- **Adding a shorthand**: add to `scanFlagShorthands` map\n- **Adding a path-like flag**: add its name to `inferStringMeta` so it gets `PATH` label\n- **Adding a glob-like flag**: add its name to `inferStringMeta` so it gets `GLOB` label\n- **Adding a new global flag**: add to the `globals` map inside `printScanFlags`\n\n### Manual verification\n\nAfter any flag change, build and check output visually:\n\n```bash\ngo build -o \u002Ftmp\u002Fskeptic-test .\u002Fcmd\u002Fskeptic\u002F\n\u002Ftmp\u002Fskeptic-test scan --help 2>&1 | head -80\nrm -f \u002Ftmp\u002Fskeptic-test\n```\n\nVerify: no duplicate entries, no single-dash long flags, shorthands merged,\ntype hints make sense, globals not repeated in scan section.\n\n## Global vs Local Decision\n\n### When a flag should be global\n\nA flag belongs in `extractGlobalFlags` (pre-parsed before subcommand dispatch)\nwhen **all** of these are true:\n\n1. It applies to **every** subcommand (or nearly every one).\n2. It controls **infrastructure** (logging, profiling, config loading), not scan behavior.\n3. It does not conflict with a subcommand-specific flag of the same name.\n\nCurrent globals: `--verbose\u002F-v`, `--quiet\u002F-q`, `--cpu-profile`, `--mem-profile`,\n`--trace`, `--perf-debug`, `--log-file`, `--config\u002F-c`.\n\n### When a flag should be local\n\nA flag is local when:\n\n- It only makes sense for one subcommand (e.g. `--bind` for `serve`).\n- It controls scan behavior that varies by context (e.g. `--scan-style`).\n- It has a subcommand-specific default (e.g. `--fail-on` defaults differ).\n\n### Passthrough patterns\n\n| Pattern | When to use | Example |\n|---------|-------------|---------|\n| Direct field access (`gf.Verbosity`) | Subcommand handler is in `cmd\u002Fskeptic\u002F` and receives `globalFlags` | corpus subcommands |\n| `mergeGlobalFlagsIntoArgs` | Subcommand parses its own `FlagSet` in `internal\u002F` and needs globals as argv | `ingest`, default scan |\n| Prepend `--config` only | Subcommand only needs config path from globals | `waive`, `serve`, `mcp` |\n| `globalProfileAndStop` only | Subcommand only needs profiling from globals | `bundle`, `export-evidence` |\n\nWhen adding a new subcommand, choose the **simplest** pattern that covers the\nglobals it needs. Do not merge all globals if only config is needed.\n\n## Test Isolation for Config-Loading Code\n\nAny test that calls `run()`, `performSkepticRun()`, or `ResolveConfigLayers()`\nexercises the config auto-discovery path: `LoadConfigValues` → `DiscoverConfigPath`\n→ `ActiveProfilePath`. If `XDG_DATA_HOME` is not isolated, the test picks up the\ndeveloper's real XDG profile (e.g. `~\u002F.local\u002Fshare\u002Fskeptic\u002Fprofiles\u002Fdev.json`),\nwhich can set `preset`, `format`, `waivers`, and other values that silently change\ntest behavior.\n\n### Required isolation\n\n```go\nfunc TestAnythingThatCallsRun(t *testing.T) {\n    t.Setenv(\"XDG_DATA_HOME\", t.TempDir())  \u002F\u002F FIRST LINE\n    \u002F\u002F ... rest of test\n}\n```\n\n### When isolation is required\n\n| Calls | Needs `XDG_DATA_HOME` isolation? |\n|-------|----------------------------------|\n| `run(...)` | **Yes** — always |\n| `performSkepticRun(...)` | **Yes** — always |\n| `ResolveConfigLayers(...)` | **Yes** — always |\n| `LoadConfigValues(...)` | **Yes** — always |\n| `DiscoverConfigPath()` | **Yes** — always |\n| `ActiveProfilePath()` \u002F `ActiveProfileName()` | **Yes** — always |\n| `LoadSystemConfig(\"\")` (empty path) | **Yes** — auto-discovers from XDG |\n| `LoadSystemConfig(\"\u002Fexplicit\u002Fpath\")` | No — explicit path bypasses discovery |\n| `ApplyRunConfigValues(...)` | No — pure value merge, no filesystem access |\n| `FlagWasSet(...)` \u002F `VisitedFlagNames(...)` | No — pure map lookups |\n| Validation-only tests (exit code 2 before config loads) | Technically safe but **still isolate** for robustness |\n\n### Audit checklist\n\nWhen reviewing tests:\n\n1. Search `cmd\u002Fskeptic\u002F*_test.go` and `internal\u002Fconfig\u002F*_test.go` for `run(`, `performSkepticRun(`, `ResolveConfigLayers(`\n2. Verify each match has `t.Setenv(\"XDG_DATA_HOME\", t.TempDir())` before the call\n3. If the test also uses `os.Chdir`, the `XDG_DATA_HOME` setenv must come **before** the chdir\n\n## Verification\n\nAfter any flag change:\n\n```bash\ngo fmt .\u002F...\ngo vet .\u002F...\ngo build .\u002F...\ngo test -race -count=1 .\u002Fcmd\u002Fskeptic\u002F .\u002Finternal\u002Fconfig\u002F .\u002Finternal\u002Fcorpus\u002F\n```\n\nCheck `--help` output for each modified subcommand to verify formatting.\n\n## Quick Checklist — Adding a New Shorthand\n\n- [ ] Register both `fs.*Var(&field, \"long-name\", ...)` and `fs.*Var(&field, \"x\", ...)` in `registerRunFlags`\n- [ ] Use identical help text for both (no `(shorthand)` suffix)\n- [ ] Add `\"long-name\": \"x\"` to `flagShorthands` in `ApplyRunConfigValues` (`internal\u002Fconfig\u002Fconfig.go`)\n- [ ] Add `\"x\": \"long-name\"` to `scanFlagShorthands` in `main.go`\n- [ ] If the flag is also checked directly in `ResolveConfigLayers`, update that call site\n- [ ] Add a test case to `TestApplyRunConfigValuesShorthandFlagPrecedence` verifying the shorthand blocks config override\n- [ ] Run `go test -race -count=1 .\u002Fcmd\u002Fskeptic\u002F .\u002Finternal\u002Fconfig\u002F`\n- [ ] Build and visually verify `--help` output shows merged `-x, --long-name` line\n",{"name":5,"description":7},"main","c712742a4c0e0d44b1ab5ed65e93e93288c2fb3d",".agents\u002Fskills\u002Fcli-flag-review",0,"https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic","https:\u002F\u002Fskeptic.sh","https:\u002F\u002Fgithub.com\u002FTGPSKI","pate.sh","Principal Software Engineer, App SRE @ Red Hat","2026-08-27 15:30:12",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add TGPSKI\u002Fskeptic --skill cli-flag-review",{"tool":60,"command":61},"bunx","bunx skills add TGPSKI\u002Fskeptic --skill cli-flag-review",{"tool":63,"command":64},"pnpm","pnpm dlx skills add TGPSKI\u002Fskeptic --skill cli-flag-review","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcli-flag-review\u002FSKILL.md",true,[],[69,78,87,113,136,153],{"skillNo":70,"name":71,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":39},"01M6K228SZDWW2VHNSZ7C2SY9B","correlation-multi","https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002Ftestdata\u002Fproof\u002Fcorrelation-multi\u002Fskill.md",[],[75,76,77],"correlation multi","multi","correlation",{"skillNo":79,"name":80,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":39},"01M6K223W4DGD1TH0CHNY5QAVS","agentic-mcp-creds","https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002Ftestdata\u002Fproof\u002Fagentic-mcp-creds\u002FSKILL.md",[],[84,85,86],"MCP","agentic","agentic mcp creds",{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":39},"01M6K21Y9Q62SEJFV60JPCB274","workflow-action-updates","Audit and update GitHub Actions workflow files to use the latest action releases pinned to full commit SHAs. Scans all .github\u002Fworkflows\u002F*.yml files, resolves current vs latest versions, and applies upgrades. Use when the user asks to update actions, check for outdated workflow dependencies, pin actions to SHAs, or audit CI workflow hygiene.","https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fworkflow-action-updates\u002FSKILL.md",[],[94,95,96,97,98,99,100,37,101,102,103,104,105,106,107,108,109,110,111,112],"workflow","action","workflow action updates","updates","commit","workflows","update","actions","ci","for","github actions","pin","check","upgrades","use","releases","files","full","github actions workflow",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":39},"01M6K21NBNBDKEMYY6VZB5V6SY","threat-rules-ingestion","Ingest fresh security research from URLs\u002Ffiles, generate signed scanner rule packs, and validate with policy and behavior scan styles across ecosystems. Use when the user asks to operationalize new threat intel into skeptic detections.","https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fthreat-rules-ingestion\u002FSKILL.md",[],[120,121,122,123,124,125,126,127,128,28,108,129,130,31,131,132,133,134,135,110],"ingestion","threat","Rules","threat rules ingestion","ecosystems","with","styles","security research","fresh","scan","scanner","ingest","generate","research","policy","security",{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":142,"publishedAt":39},"01M6K21GBVZP22D2R0FPGG8P1J","ruleset-lifecycle-operations","Add or update rule definitions, create and manage rule groups, and migrate rules across groups in skeptic using the property-based layout. Use when the user asks to add\u002Fupdate rules, add\u002Fmanage groups, or reorganize `internal\u002Frules`.","https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fruleset-lifecycle-operations\u002FSKILL.md",[],[143,144,145,146,147,148,149,28,150,31,108,151,122,152,100],"ruleset lifecycle operations","operations","lifecycle","create","layout","rule","add","manage","user","migrate",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":39},"01M6K21CP4GEXZ0GN7C5M1DBXF","go-release","Manage the full Go module release lifecycle: determine next semver version, update CHANGELOG.md, create and push a git tag, and verify pkg.go.dev picks up the new version. Use when the user asks to tag a release, bump the version, update the changelog, or publish a new module version.","https:\u002F\u002Fgithub.com\u002FTGPSKI\u002Fskeptic\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgo-release\u002FSKILL.md",[],[160,161,162,145,163,111,164,150,165,166,108,167,168,169,170,171,172,173,100,146],"go","go release","release","module","next","bump","up","update changelog","publish","push","changelog","dev","semver","git"]