You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .agents/skills/add-command-spec/SKILL.md
+61-17Lines changed: 61 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,22 +5,56 @@ description: Guide for adding new command completion specs to warp-command-signa
5
5
6
6
# Adding a New Command Spec
7
7
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.
9
9
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
12
11
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
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
14
48
15
49
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.
16
50
17
-
### Common pitfalls
51
+
####Common pitfalls
18
52
19
53
- Commands that work differently across platforms (for example, user lookup via `dscl` on macOS vs `getent` on Linux)
20
54
- Commands with different output formats across platforms
21
55
- Hardcoded paths that differ between systems
22
56
23
-
### Solutions
57
+
####Solutions
24
58
25
59
Identify which platforms the command needs to support.
26
60
@@ -35,7 +69,7 @@ Prioritize approaches in this order:
35
69
36
70
Implement platform-specific logic in the generator only when behavior fundamentally differs across systems.
37
71
38
-
## Generator Reusability
72
+
###Generator Reusability
39
73
40
74
Generators that are shared by multiple commands should live in `command-signatures/src/generators/common.rs`. Before implementing a new generator:
41
75
@@ -46,11 +80,11 @@ Generators that are shared by multiple commands should live in `command-signatur
46
80
47
81
See `fn users_generator()` in `common.rs` as an example of a cross-platform generator used by multiple commands.
48
82
49
-
## Style Guideline
83
+
###Style Guideline
50
84
51
85
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.
52
86
53
-
### Documenting Argument Formats
87
+
####Documenting Argument Formats
54
88
55
89
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.
56
90
@@ -62,21 +96,31 @@ Example:
62
96
}
63
97
```
64
98
65
-
## Validation
99
+
## Step 3: Validation
66
100
67
101
Format the JSON spec with `npm run format -- command-signatures/json/<command>.json`.
68
102
69
103
Run `script/presubmit` to verify formatting, linting, and tests all pass (this runs `cargo fmt --check`, `cargo clippy`, and `cargo test`).
70
104
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.
78
119
79
120
## Reference Examples
80
121
81
122
-**Simple spec with generator**: `json/kill.json` + `src/generators/kill.rs` — minimal example showing `generatorName` usage for process and signal completions
82
123
-**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