Skip to content

fix(cli): exit non-zero when skills info cannot find a skill - #123997

Merged
steipete merged 1 commit into
mainfrom
steipete/skills-info-exit-code
Aug 15, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/skills-info-exit-code

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where openclaw skills info <missing> printed a clear not-found result but exited 0, so shell conditionals and machine consumers treated a missing skill as present.

The human and JSON payloads were already correct; only the process status contradicted them.

Why This Change Was Made

The command action now resolves the requested skill with the same canonical resolver used by the formatter, writes the existing formatter output unchanged, and exits 1 when resolution fails. This keeps the exported formatSkillInfo string contract intact instead of widening it with command-status metadata.

The direct structural sibling, hooks info, follows the same separation: format output first, then derive the command status independently from the report.

User Impact

Scripts can safely use openclaw skills info NAME && ..., and machine consumers can trust a non-zero status for missing skills. Existing skills still exit 0. Human text and JSON keys are unchanged.

Evidence

Before

Reproduced with the packaged CLI before the patch:

$ openclaw skills info nope-not-real --agent main
Skill "nope-not-real" not found. Run `openclaw skills list` to see available skills.

Tip: use `openclaw skills search`, `openclaw skills install`, and `openclaw skills update` for ClawHub-backed skills.
$ echo $?
0

$ openclaw skills info nope-not-real --agent main --json
{
  "error": "not found",
  "skill": "nope-not-real"
}
$ echo $?
0

Sibling behavior at the same boundary:

Command Missing-result exit
cron show <bogus> 1
approvals resolve <bogus> 1
config get <missing path> 1
agents delete <bogus> 1
hooks info <bogus> 1
skills info <bogus> before this patch 0

hooks info --json returns { "error": "not found", "hook": NAME } and exits 1; skills info --json keeps its parallel { "error": "not found", "skill": NAME } shape and now also exits 1.

After: built CLI, isolated state

Built the exact branch, then ran with a fresh OPENCLAW_STATE_DIR and OPENCLAW_SKIP_CHANNELS=1:

Command Exit
skills info nope-not-real --agent main 1
skills info nope-not-real --agent main --json 1
skills info skill-creator --agent main 0
skills info skill-creator --agent main --json 0
hooks info nope-not-real --agent main 1
hooks info nope-not-real --agent main --json 1
config get nope.not.real --json 1
agents delete nope-not-real --force 1

The missing human text and pretty-printed JSON were byte-identical to the baseline payloads. The existing JSON still reported "name": "skill-creator".

Skills surface sweep

Surface Checked exit behavior
default / list Valid empty or populated report: 0; load error: 1
info Existing: 0; missing: 1 after this patch
check Diagnostic report, including missing requirements: 0; load error: 1
search Empty results: 0; invalid input or registry failure: 1
install Invalid input and install failures: 1
update Missing/conflicting selection or failed update: 1; empty --all: intentional no-op 0
verify Resolution, card, verification, malformed-envelope, and transport failures: 1
curator status Successful current report: 0; current read failure: 1
curator pin / unpin / restore Missing skill and mutation failures: 1
workshop parent / list Help or empty proposal list: 0
workshop inspect and mutations Missing proposal/input and service failures: 1

Repo-wide src/cli/** search found only two formatter-returned top-level { error: "not found" } payloads: skills and hooks. Hooks was already correct. Other direct JSON error writers checked (config, directory, system, webhooks, node/gateway status, doctor, and database) already exit non-zero.

Named follow-up: define plugins doctor exit semantics when its report has ok: false. Its report mixes hard load errors with warnings, so changing that broader diagnostic contract needs a separate product-policy decision rather than riding this focused not-found fix.

Validation

  • Pre-fix regression proof: both new missing-skill cases failed because the command resolved instead of exiting.
  • node scripts/run-vitest.mjs src/cli/skills-cli.commands.test.ts src/cli/skills-cli.test.ts src/cli/skills-cli.formatting.test.ts src/cli/hooks-cli.test.ts — 123 passed.
  • node scripts/check-changed.mjs -- src/cli/skills-cli.ts src/cli/skills-cli.commands.test.ts — passed on Blacksmith Testbox (types, lint, formatting, dead-code and boundary guards).
  • pnpm build on Blacksmith Testbox — passed.
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output — clean; no accepted/actionable findings.
  • Post-rebase focused command test — 3 passed.

AI-assisted: implementation, sweep, and validation were performed with Codex; the behavior and diff were reviewed directly.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 15, 2026 03:59
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 12:17 AM ET / 04:17 UTC.

ClawSweeper review

What this changes

This PR makes openclaw skills info &lt;missing> exit with status 1 while preserving its human-readable and JSON output.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness or security finding: this is a focused fix for a source-proven CLI contract bug. Keep it open for the maintainer’s land decision after exact-head checks complete.

Priority: P2
Reviewed head: 506e1400eb4f700595a8b88b2c13a8d43a4d9b81
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned repair with command-boundary coverage; only routine exact-head CI completion remains before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored, maintainer-labeled PR body records before-and-after built CLI terminal behavior; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored, maintainer-labeled PR body records before-and-after built CLI terminal behavior; the external-contributor proof gate does not apply.
Evidence reviewed 6 items Current-main bug: Current main writes formatSkillInfo output through runSkillsAction, but the info action has no missing-skill status decision; the formatter returns a not-found payload without throwing.
Canonical lookup contract: The formatter uses resolveSkillStatusEntry; it returns null for no unique match, so the branch can derive status from the same report and resolver without changing the output contract.
Proposed repair and regression coverage: The branch writes the existing formatter output, then exits 1 only when the canonical resolver finds no skill; command-boundary tests cover human and JSON missing cases plus a successful lookup.
Findings None None.
Security None None.

How this fits together

The Skills CLI obtains a workspace status report, resolves a requested skill, writes formatted output, and signals success or failure to shell scripts. This affects local automation that branches on the command’s exit status.

flowchart LR
  A[CLI arguments] --> B[Skills info command]
  B --> C[Workspace status report]
  C --> D[Canonical skill lookup]
  D --> E[Human or JSON output]
  D --> F[Shell exit status]
Loading

Decision needed

Question Recommendation
After exact-head checks complete, should this maintainer-authored, maintainer-labeled CLI correction land? Land after exact-head CI: Merge the focused repair once required checks are green; it aligns missing-skill behavior with the established CLI status contract.

Why: Repository policy keeps maintainer-authored and maintainer-labeled work out of automated closure or cleanup paths even when the patch is correct.

Before merge

  • Resolve merge risk (P1) - Exact-head required checks were still in progress in the supplied PR state; merge only after they finish green.
Agent review details

Security

None.

PR surface

Source +4, Tests +36. Total +40 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 10 6 +4
Tests 1 37 1 +36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 47 7 +40

Review metrics

Metric Value Why it matters
Production vs test LOC production +10/-6 (net +4); tests +37/-1 (net +36) The small production increase preserves the existing formatter string contract; the added command-boundary tests cover both output modes and successful lookup behavior.

Stored data model

Persistent data-model change detected: serialized state: src/cli/skills-cli.commands.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused status fix after exact-head CI passes, retaining the separate canonical lookup because changing the exported string-only formatter contract would broaden the public surface for no functional gain.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused status fix after exact-head CI passes, retaining the separate canonical lookup because changing the exported string-only formatter contract would broaden the public surface for no functional gain.

Do we have a high-confidence way to reproduce the issue?

Yes — source-reproducible with high confidence: current main formats a missing skill as output but does not request a non-zero exit. Local execution could not start in the read-only environment because Corepack requires a writable cache.

Is this the best way to solve the issue?

Yes — the command derives status from the same canonical resolver already used for output, matching the Hooks CLI separation without widening the formatter’s exported string-only contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 622eec9c364f.

Labels

Label justifications:

  • P2: A wrong exit status misleads shell automation for a bounded CLI lookup, but it is not an emergency availability or security issue.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored, maintainer-labeled PR body records before-and-after built CLI terminal behavior; the external-contributor proof gate does not apply.

Evidence

What I checked:

  • Current-main bug: Current main writes formatSkillInfo output through runSkillsAction, but the info action has no missing-skill status decision; the formatter returns a not-found payload without throwing. (src/cli/skills-cli.ts:1238, 622eec9c364f)
  • Canonical lookup contract: The formatter uses resolveSkillStatusEntry; it returns null for no unique match, so the branch can derive status from the same report and resolver without changing the output contract. (src/skills/discovery/status.ts:89, 506e1400eb4f)
  • Proposed repair and regression coverage: The branch writes the existing formatter output, then exits 1 only when the canonical resolver finds no skill; command-boundary tests cover human and JSON missing cases plus a successful lookup. (src/cli/skills-cli.commands.test.ts:1382, 506e1400eb4f)
  • Sibling and documented CLI precedent: hooks info writes its existing not-found payload then independently returns status 1, and the documented config get missing-path JSON behavior also exits 1. (src/cli/hooks-cli.ts:650, 506e1400eb4f)
  • Area provenance: The current Skills CLI was most recently maintained by Peter Steinberger in the merged main commit that updated its error formatting; this PR is a subsequent focused repair in the same file. (src/cli/skills-cli.ts:1238, 2463ea0a5e64)
  • Local execution limitation: The required docs listing and local test route could not start because Corepack attempted to create its cache on the read-only filesystem; the checkout remained clean, so this is not missing contributor proof.

Likely related people:

  • steipete: Authored the latest merged main touch to the affected CLI file and has the strongest visible history concentration in the Skills CLI/status area. (role: recent CLI contributor; confidence: high; commits: 2463ea0a5e64, 506e1400eb4f; files: src/cli/skills-cli.ts, src/cli/skills-cli.commands.test.ts, src/skills/discovery/status.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the required exact-head checks complete green before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-15T04:05:34.572Z sha 110e45da147a7a641e869223ca742e25e49354b4 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/skills-info-exit-code branch from 110e45d to 506e140 Compare August 15, 2026 04:12
@steipete
steipete merged commit 289c31a into main Aug 15, 2026
185 checks passed
@steipete
steipete deleted the steipete/skills-info-exit-code branch August 15, 2026 04:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant