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
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,42 @@ description: Guide for adding new command completion specs to warp-command-signa
10
10
1.**Create JSON spec**: `command-signatures/json/<command>.json` following the [Fig completion spec schema](https://fig.io/docs/reference)
11
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`
12
12
13
+
## Platform Compatibility
14
+
15
+
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
+
17
+
### Common pitfalls
18
+
19
+
- Commands that work differently across platforms (for example, user lookup via `dscl` on macOS vs `getent` on Linux)
20
+
- Commands with different output formats across platforms
21
+
- Hardcoded paths that differ between systems
22
+
23
+
### Solutions
24
+
25
+
Identify which platforms the command needs to support.
26
+
27
+
Prioritize approaches in this order:
28
+
29
+
1.**Use cross-platform commands** when available — commands that work identically on the relevant platforms minimize maintenance burden. However, this is not always possible.
30
+
2.**Feature detection** — prefer testing for command availability or flag support over platform checks:
31
+
-`command -v <cmd>` to check if a tool exists, see `fn users_generator()` in `command-signatures/src/generators/common.rs` for an example.
32
+
-`<cmd> --version 2>/dev/null` or `<cmd> --help` to test flag support
33
+
3.**Graceful fallbacks** — when a platform-specific tool is unavailable, fall back to portable alternatives (e.g., `getent` → `dscl` → `/etc/passwd`).
34
+
4.**Platform detection as last resort** — only use `uname` or similar if the above approaches are insufficient.
35
+
36
+
Implement platform-specific logic in the generator only when behavior fundamentally differs across systems.
37
+
38
+
## Generator Reusability
39
+
40
+
Generators that are shared by multiple commands should live in `command-signatures/src/generators/common.rs`. Before implementing a new generator:
41
+
42
+
1. Search the codebase to see if a similar generator has already been implemented by another command.
43
+
2. If one exists and can be reused, use it directly.
44
+
3. If a generator is used across multiple commands, move it to `common.rs` for reuse.
45
+
4. Generators that are only used by a single command should remain in their own module (e.g., `command-signatures/src/generators/<command>.rs`).
46
+
47
+
See `fn users_generator()` in `common.rs` as an example of a cross-platform generator used by multiple commands.
48
+
13
49
## Style Guideline
14
50
15
51
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.
0 commit comments