Skip to content

Commit 703ddea

Browse files
authored
Augment add-command-spec skill (#206)
1 parent 60cf115 commit 703ddea

1 file changed

Lines changed: 61 additions & 17 deletions

File tree

.agents/skills/add-command-spec/SKILL.md

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,56 @@ description: Guide for adding new command completion specs to warp-command-signa
55

66
# Adding a New Command Spec
77

8-
## Steps
8+
This skill covers the full lifecycle of writing a completion spec in warpdotdev/command-signatures: researching the command, writing the spec, validating it, and submitting it.
99

10-
1. **Create JSON spec**: `command-signatures/json/<command>.json` following the [Fig completion spec schema](https://fig.io/docs/reference)
11-
2. **Create generator** (if needed): Add `command-signatures/src/generators/<command>.rs`, define a `generator()` function returning `CommandSignatureGenerators`, and register it in `generators/mod.rs`
10+
## Step 1: Research the Command
1211

13-
## Platform Compatibility
12+
Before writing any JSON, build a thorough picture of the command's subcommands, flags, and argument types. Commands often have more surface area than you'd expect — nested subcommands, platform-specific flags, mutually exclusive options. Investing time here prevents rework later.
13+
14+
Use these strategies roughly in priority order:
15+
16+
### Start with Fish shell completions
17+
18+
Fish maintains high-quality, community-reviewed completion definitions at https://github.com/fish-shell/fish-shell/tree/master/share/completions — look for `<command>.fish`. These are thorough and well-structured, so they're the fastest way to get a comprehensive picture of a command's subcommands and flags. Read this file first.
19+
20+
### Test with Fish shell completions
21+
22+
You can also use Fish's completion engine to test output interactively:
23+
24+
1. Install Fish if needed (`brew install fish` on UNIX)
25+
2. Run: `fish -c 'complete -C "<command> "'` to see top-level completions
26+
3. Drill into subcommands: `fish -c 'complete -C "<command> <subcommand> "'`
27+
28+
For example, to inspect `gcloud compute ssh` completions: `fish -c 'complete -C "gcloud compute ssh w"'` (where `w` is the start of a known target).
29+
30+
### Install and inspect the command directly
31+
32+
Use the command's own documentation to fill gaps and verify what Fish reports. Install the command if it isn't already available, then:
33+
34+
- Check the `man` page (pipe to `cat` to avoid the pager): `man <command> | cat`
35+
- Run `<command> --help` and `<command> help` at each subcommand level to discover nested structure
36+
- Run the command itself to observe real output — this matters for generators that parse command output
37+
38+
### Use Fig specs as a last resort
39+
40+
The Fig autocomplete repo at https://github.com/withfig/autocomplete/tree/master/src has TypeScript specs for many commands (look for `<command>.ts`). These can help fill gaps, but they vary in quality and may be outdated — always verify against the command's own docs.
41+
42+
## Step 2: Implement the Spec
43+
44+
1. **Create the JSON spec**: `command-signatures/json/<command>.json` following Fig's completion spec schema and the reference examples.
45+
2. **Create a generator** (if needed): Add `command-signatures/src/generators/<command>.rs`, define a `generator()` function returning `CommandSignatureGenerators`, and register it in `generators/mod.rs`
46+
47+
### Platform Compatibility
1448

1549
When implementing generator commands, ensure they work across all applicable platforms where the command exists. For example, a UNIX-only command should work on both macOS and Linux, not just the platform being used for development.
1650

17-
### Common pitfalls
51+
#### Common pitfalls
1852

1953
- Commands that work differently across platforms (for example, user lookup via `dscl` on macOS vs `getent` on Linux)
2054
- Commands with different output formats across platforms
2155
- Hardcoded paths that differ between systems
2256

23-
### Solutions
57+
#### Solutions
2458

2559
Identify which platforms the command needs to support.
2660

@@ -35,7 +69,7 @@ Prioritize approaches in this order:
3569

3670
Implement platform-specific logic in the generator only when behavior fundamentally differs across systems.
3771

38-
## Generator Reusability
72+
### Generator Reusability
3973

4074
Generators that are shared by multiple commands should live in `command-signatures/src/generators/common.rs`. Before implementing a new generator:
4175

@@ -46,11 +80,11 @@ Generators that are shared by multiple commands should live in `command-signatur
4680

4781
See `fn users_generator()` in `common.rs` as an example of a cross-platform generator used by multiple commands.
4882

49-
## Style Guideline
83+
### Style Guideline
5084

5185
Match the formatting conventions used in the command's `--help` output. For example, if the help text uses `UPPER_CASE` for positional argument names, use the same casing in the spec's argument `name` field.
5286

53-
### Documenting Argument Formats
87+
#### Documenting Argument Formats
5488

5589
If an argument has a specific format (date, time, pattern, etc.), document it in the argument's `description` field. This helps users understand the expected input format.
5690

@@ -62,21 +96,31 @@ Example:
6296
}
6397
```
6498

65-
## Validation
99+
## Step 3: Validation
66100

67101
Format the JSON spec with `npm run format -- command-signatures/json/<command>.json`.
68102

69103
Run `script/presubmit` to verify formatting, linting, and tests all pass (this runs `cargo fmt --check`, `cargo clippy`, and `cargo test`).
70104

71-
To verify completions end-to-end in a real Warp session, use the **test-local-warp** skill, which covers building and running Warp against a local checkout of this repo.
72-
This requires computer use to be enabled since Warp is a GUI application.
73-
Use this when adding generators to make sure they produce reasonable candidates.
74-
If you are running unsupervised (autonomy level is `UNSUPERVISED`), this step is required.
75-
Produce screenshots for each generator added so that a human can review them. You do not need to zoom in.
76-
We only need screenshots for generator functions. Things like sub-commands and options are already well tested.
77-
When running supervised, skip this step.
105+
Static sub-commands and options are already well-tested.
106+
107+
Generators require end-to-end verification to make sure they produce reasonable candidates. To verify generator completions end-to-end in a real Warp session, use the `test-local-warp` skill in `command-signatures/.agents/skills/test-local-warp/` which covers building and running Warp against a local checkout of the `command-signatures` repo. This requires computer use to be enabled since Warp is a GUI application.
108+
Use a local warp build to install and set up the command and test the newly-written generators. To trigger the completions menu, press the `tab` key. Remember that we're NOT testing autocomplete (ghost text), but rather testing completions, which are dropdown menus that appear next to the cursor. Take a screenshot to show each generator working; your work will not be accepted without it. You do not need to zoom in.
109+
110+
## Step 4: Submitting
111+
112+
Title the branch according to the Linear issue, eg: `app-####/command-spec-<command-name>`.
113+
Title the PR: **Add completion spec: `<command full name> [short-name])`**, where `<command full name>` is the command's full, human-readable name (eg. "ripgrep"). `[short-name]` is the command's CLI invocation, if it exists, in parentheses (eg. "(rg)").
114+
For example, adding support for openshift would be done in a branch called `app-3507/command-spec-openshift` and a PR titled "Add completion spec: openshift (oc)".
115+
116+
A consistent title convention makes it easy to scan PR history and understand what was added at a glance.
117+
118+
Attach screenshots for each generator in the PR body.
78119

79120
## Reference Examples
80121

81122
- **Simple spec with generator**: `json/kill.json` + `src/generators/kill.rs` — minimal example showing `generatorName` usage for process and signal completions
82123
- **Complex spec with multiple generators**: `json/brew.json` + `src/generators/brew.rs` — shows subcommands, options, and multiple generators (`formulae_generator`, `services`, etc.)
124+
- **Context-aware generators and aliases**: `src/generators/git.rs` — demonstrates `command_from_tokens` (flag-dependent behavior) and `add_alias` (git alias expansion)
125+
- **Multi-command module with shared helpers**: `src/generators/npm.rs` — single module exporting generators for `npm`, `yarn`, and `pnpm`, reusing `get_scripts_generator()` and `dependencies_generator()`
126+
- **Parsing structured output**: `src/generators/cargo.rs` — generators that parse JSON from `cargo metadata` using serde deserialization

0 commit comments

Comments
 (0)