Skip to content

Capture judgment: cobra mining, anti-patterns, skills lint#3

Merged
bueti merged 1 commit into
mainfrom
v0.3-judgment
Apr 18, 2026
Merged

Capture judgment: cobra mining, anti-patterns, skills lint#3
bueti merged 1 commit into
mainfrom
v0.3-judgment

Conversation

@bueti
Copy link
Copy Markdown
Owner

@bueti bueti commented Apr 18, 2026

Summary

Cobra field mining

Before consulting annotations, the generator now extracts free signal:

  • cmd.Aliases → render as an Aliases: … note and auto-derive trigger phrases when skill.trigger is unset ("Use when the user asks to deploy, ship, or release").
  • cmd.Deprecated → renders a prominent > **Deprecated:** … callout.
  • flag.Deprecated → filtered from the rendered flag list entirely.

Also refactored: deriveDescription collapses three previously duplicated description-composition blocks (single / leaf / overview) so the alias fallback applies consistently.

Anti-pattern annotations

  • skill.avoid — free-form Markdown rendered as a ## Avoid section (bold inline label inside nested command sections).
  • skill.prefer-over — same treatment under ## Prefer over.

These capture the single highest-value content in most real skills: what not to do.

skills lint

  • Generator.Lint() walks the same tree the generator walks (honors Hidden / skill.skip / WithSkip / cobra builtins) and returns []Issue.
  • Errors for missing descriptions; warnings for short Short, missing trigger signal on root/leaves, and deprecated commands without a useful message.
  • skills lint subcommand prints findings + summary, exits 1 on any error. --strict promotes warnings to errors for CI.

Test plan

  • go build ./...
  • go test ./... — 14 new tests in judgment_test.go pass alongside the existing suite
  • go vet ./...
  • golangci-lint run ./... — 0 issues
  • go run ./example skills lint — 3 trigger warnings, exit 0
  • go run ./example skills lint --strict — same output, exit 1
  • go run ./example skills print — aliases/deprecated/anti-pattern sections render as expected when wired into cobra commands
  • CI matrix (Linux / macOS / Windows on Go 1.25) once it runs on the PR

The v0.2 library optimized for coverage (every command documented).
The bottleneck for agent usefulness is judgment — when to trigger and
what to avoid. This commit captures that judgment cheaply, in three
coordinated changes.

Cobra field mining
------------------
Before consulting annotations, the generator now reads free signal
from the command tree:

- cmd.Aliases render as "Aliases: `ship`, `release`" and auto-derive a
  trigger suffix when skill.trigger is unset ("Use when the user asks
  to deploy, ship, or release").
- cmd.Deprecated renders a prominent "> **Deprecated:** …" callout so
  agents are warned off the command and see the replacement.
- Deprecated flags (pflag.Flag.Deprecated) are filtered from the
  rendered flag list entirely — the author already said the flag
  shouldn't be suggested.

deriveDescription consolidates the three previously duplicated
description-composition blocks (single / leaf / overview) so the alias
fallback applies consistently.

Anti-pattern annotations
------------------------
Two new annotations, the single highest-value content in most real
skills:

- skill.avoid — free-form Markdown rendered as a ## Avoid section in
  root / leaf bodies and as a bold inline label inside nested command
  sections.
- skill.prefer-over — same treatment under ## Prefer over, for
  pointing the agent away from competing tools or commands this one
  supersedes.

skills lint
-----------
Generator.Lint() walks the same tree the generator walks (honoring
Hidden, skill.skip, WithSkip, and the cobra-builtin filter) and
returns []Issue — errors for missing descriptions, warnings for short
Short, missing trigger signal on root/leaves, and deprecated commands
without a useful message. `skills lint` prints the findings; exit
code is 1 on any error, and --strict promotes warnings to errors for
CI enforcement.

Tests
-----
14 new tests in judgment_test.go covering alias rendering + trigger
derivation, explicit trigger precedence, deprecated callouts, flag
filtering, anti-pattern sections (root-level and nested), lint's
positive and negative paths, skip honoring, sort order, and the empty
case of FormatIssues.

Docs
----
README gains an annotations row for skill.avoid / skill.prefer-over,
a new "What's mined from cobra" section, and a "Linting" section with
a GitHub Actions snippet. CHANGELOG picks up the three Added entries
under Unreleased.
@bueti bueti merged commit be27854 into main Apr 18, 2026
4 checks passed
@bueti bueti deleted the v0.3-judgment branch April 18, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant