Skip to content

Fix render skills list and remove crashing with -o text, json or yaml - #80

Closed
gorban wants to merge 6 commits into
render-oss:mainfrom
gorban:fix-skills-list-noninteractive
Closed

gorban wants to merge 6 commits into
render-oss:mainfrom
gorban:fix-skills-list-noninteractive

Conversation

@gorban

@gorban gorban commented Dec 3, 2026 •

Copy link
Copy Markdown

Summary

render skills list, render skills update, bare render skills, and render skills remove without --all or --skill panicked with --output text, json or yaml, and on any run without a TTY (which falls back to text). Each pushed a TUI view onto the stack from the context, and outside interactive mode there is no stack, so Push ran on a nil *StackModel. Running in a terminal doesn't avoid it: -o text is enough.

Non-interactive output now goes through command.NonInteractive, as skills install already does. Interactive mode is unchanged.

  • JSON / YAML print skills.ListResult (in pkg/skills/list.go, next to InstallResult): installed skills with version and scope, filtered by --scope; the tools recorded in state with whether each is detected and its skills folder (in the current repository for --scope project, and left out outside one); the install time; and any warnings. Keys are camelCase. (skills install -o json prints Go field names such as SkillsDir and dry_run; changing that would break existing scripts, so it's left alone here.) Empty lists print as [], and the unknown version placeholder is left out.
  • Text prints two tables from text.SkillTables (in pkg/text, like the other list tables), with - for empty cells. With nothing installed it prints just the headers, as other tables do; the interactive view keeps its "Run render skills install" hint.
  • Warnings from reading installed skills go to stderr for text, styled like other warnings, so they don't mix into the tables. JSON and YAML carry them in warnings only, so stdout and stderr stay clean for scripts.
  • skills remove without --all or --skill needs the prompt to choose skills, so outside interactive mode it now returns --all or --skill is required in non-interactive mode, the form psql and ssh use for required non-interactive input. With either flag it works as before.
  • skills update returns `render skills update` can only be used in interactive mode, the error other interactive-only commands use. A non-interactive update changes files, so it should be designed on its own.
  • Bare render skills prints its help, listing the subcommands, instead of opening the command palette. Like --help, it prints help text even with -o json.
  • The --scope filter moves into skills.FilterSkillsByScope, used by both the new output and the interactive view, so they can't disagree. The view is otherwise unchanged.
$ render skills list -o text
NAME             VERSION    SCOPE
render-deploy    1.2.0      user
render-debug     -          project

TOOL           DETECTED    SKILLS DIR
Claude Code    true        /home/u/.claude/skills
Cursor         false       -
$ cd ~/my-app && render skills list -o json --scope project
{
  "skills": [{ "name": "render-debug", "scope": "project" }],
  "tools": [
    { "name": "Claude Code", "detected": true, "skillsDir": "/home/u/my-app/.claude/skills" },
    { "name": "Cursor", "detected": false }
  ],
  "installedAt": "2026-12-03T20:00:00Z"
}

Motivation

Fixes #79. Seen in v2.35.0 and v2.40.0 on linux/amd64.

How to verify

The commits are red then green, in three pairs:

  1. Add a regression test… builds the command with newSkillsListCmd(loadState) (no behavior change) so tests can supply skills state, and runs render skills list through the root command with no TTY and with each -o format. On this commit it fails with the panic from the issue; the panic stops the test binary at the first subtest.
  2. Fix render skills list crash… makes it pass and adds tests for the JSON shape, --scope filtering, YAML, the empty state, warnings on stderr, a load error, FilterSkillsByScope and SkillTables.
  3. Add a regression test for render skills remove… builds the command with newSkillsRemoveCmd() (no behavior change) and runs it without --all or --skill: no TTY, -o text, -o json, and --confirm --tool claude --scope user -o text, as in the issue. It fails with the same panic. The no-TTY harness is shared with the list tests as executeSkillsCommand.
  4. Fix render skills remove crash… makes it pass.
  5. Add tests for the remaining render skills commands… covers skills update and bare render skills outside interactive mode, the project skills folder in skills list -o json --scope project (in a new git repository and outside one), and warnings staying out of stderr for JSON. It also checks that interactive mode still opens the list view. skills update becomes a constructor like the others (no behavior change). The harness returns a panic as an error, so each crashing case fails on its own.
  6. Fix the remaining render skills commands… makes them pass.

The tests never read the real skills state. Its path is fixed when the package loads, so the list tests supply the state through newSkillsListCmd(loadState), and the remove and update tests stop at their argument checks. HOME (and USERPROFILE) point at a temporary directory, so tool detection doesn't read the real home either. A fresh command per test keeps flag values from carrying over.

go test ./cmd/ -run 'Skills' -v
go test ./pkg/skills/ ./pkg/text/ -run 'FilterSkillsByScope|SkillTables' -v
go build -o /tmp/render . && /tmp/render skills list -o json && /tmp/render skills list | cat
/tmp/render skills remove -o text   # error naming --all and --skill
/tmp/render skills update -o text   # interactive-only error
/tmp/render skills | cat            # help

Checked with Go 1.27.4: go test ./cmd/ ./pkg/... passes (as a non-root user), gofmt, go vet and go mod tidy are clean, and golangci-lint v2.14.0 with --new-from-rev against main reports 0 issues.

This overlaps with #82 in cmd/skillsremove.go. I suggest landing this one first; #82 then carries its --tool help text into newSkillsRemoveCmd, and changes NewListResult to find tools saved as Cursor.

Release notes

- `render skills list` now prints with `--output text`, `json` or `yaml`, and without a TTY, instead of crashing
- `render skills remove` without `--all` or `--skill` now explains that one is required outside interactive mode, instead of crashing
- `render skills update` now explains that it needs interactive mode, and bare `render skills` prints its help, instead of crashing

render skills list panics with a nil pointer dereference in
tui.(*StackModel).Push when run with --output text, json or yaml, or
without a TTY, which falls back to text. The command always pushes its
TUI view onto the stack from the context, and the root command only
puts a stack in the context in interactive mode.

The test runs render skills list through the root command with no TTY
and with each non-interactive format. It fails on this commit with the
same panic as the issue.

To run the command without reading the real home directory, the command
is now built by newSkillsListCmd, which takes the function that loads
skills state. The skills state path is fixed when the package loads,
and tool detection reads the home directory, so setting HOME in a test
can't isolate either. Building a fresh command per test also keeps flag
values from carrying over between tests, as they do on a package-level
command. Behavior is unchanged.

Refs render-oss#79
render skills list pushed its TUI view onto the stack from the context
on every run. Outside interactive mode (--output text, json or yaml, or
any run without a TTY) the root command puts no stack in the context,
so the push dereferenced a nil *StackModel and panicked.

Route non-interactive output through command.NonInteractive, as skills
install already does, and only push the view in interactive mode.

- JSON and YAML print skills.ListResult: the installed skills with
  their version and scope (filtered by --scope), the tools recorded in
  the state file with whether each is detected and its skills
  directory, the install time and any warnings. Keys are camelCase like
  the CLI's other JSON output, empty lists print as [] rather than
  null, and a version of "unknown" is left out.
- Text prints a skills table and a tools table in the same table style
  as other list commands' text output, using "-" for empty cells.
- Warnings from reading installed skills also go to stderr, styled like
  other warnings there, so text output shows them without mixing them
  into the tables.

The output type lives in pkg/skills next to InstallResult, and the
table rendering in pkg/text next to the other tables. The --scope
filter moves into skills.FilterSkillsByScope, which both the new output
and the interactive view use, so the two can't disagree about which
skills are at a scope. The view is otherwise unchanged.

Fixes render-oss#79
@gorban
gorban force-pushed the fix-skills-list-noninteractive branch from 13b5a2a to cc6bdff Compare December 3, 2026 20:46
@gorban gorban changed the title Fix render skills list panic with text, json and yaml output Fix render skills list crash outside interactive mode Dec 3, 2026
Build the command with newSkillsRemoveCmd, as skills list does, so tests
run it through the root command with a fresh command each time. The no-TTY
harness moves into executeSkillsCommand, shared with the skills list tests.
Behavior is unchanged.

The test runs render skills remove without --all or --skill, with no TTY
and with -o text and -o json. It fails with the same nil pointer panic as
skills list did, from pushing the TUI view when there is no stack.

Refs render-oss#79
Without --all or --skill, render skills remove opens a prompt to choose
skills. Outside interactive mode (--output text, json or yaml, or no TTY)
there is no TUI stack, and pushing the view onto it panicked. Return an
error naming the flags instead, in the form other commands use for
required non-interactive input.

Fixes render-oss#79
@gorban gorban changed the title Fix render skills list crash outside interactive mode Fix render skills list and remove crashes outside interactive mode Dec 3, 2026
@gorban gorban changed the title Fix render skills list and remove crashes outside interactive mode Fix render skills list and remove crashing with -o text, json or yaml Dec 3, 2026
…e mode

Make `skills update` a constructor like `list` and `remove` so tests can
run it. Behavior is unchanged.

The new tests cover:
- `skills update` and bare `render skills` without a TTY or with -o
  text or json, which still panic.
- `skills list -o json --scope project`, which reports each tool's user
  skills folder rather than the project one.
- Warnings, which `skills list -o json` prints to stderr as well as
  into the output.
- Interactive mode, where `skills list` still opens its view.

The test helper now uses a temporary HOME, so tool detection never
reads the real one, and returns a panic as an error so it fails only
the test that caused it. The remove test uses `--tool claude`, as in
the issue.

Refs render-oss#79
Outside interactive mode (no TTY, or -o text, json or yaml):
- `skills update` returns "`render skills update` can only be used in
  interactive mode", the error other interactive-only commands use,
  instead of panicking.
- Bare `render skills` prints its help instead of panicking.
- `skills list -o json --scope project` reports each tool's skills
  folder in the current repository, and leaves it out outside one.
- `skills list` prints warnings to stderr only for text; JSON and YAML
  carry them in the output.

`skills remove` uses command.IsInteractive, like the commands above.

Fixes render-oss#79
@gorban

gorban commented Dec 4, 2026

Copy link
Copy Markdown
Author

Thanks for picking this up! 1e3db3e and 02c8745 cover everything this PR fixed (skills list, skills remove, skills update and bare render skills outside a terminal), and the test that runs every command without a TTY is a nicer guard than my per-command tests. I rebuilt from main and reran the repros from #79 with and without a TTY: no panics, and remove/update now explain what to run instead. Closing in favor of those.

@gorban gorban closed this Dec 4, 2026
@gorban
gorban deleted the fix-skills-list-noninteractive branch December 4, 2026 18:13
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.

render skills list and render skills remove panic with -o text, json or yaml

1 participant