Skip to content

Commit 0f22da5

Browse files
authored
feat: add Claude Code skill for Bit CLI reference (#10138)
Adds a distributable skill that provides Claude Code with accurate Bit CLI command reference, eliminating trial-and-error when running bit commands.
1 parent 9de9a2b commit 0f22da5

File tree

3 files changed

+316
-0
lines changed

3 files changed

+316
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Bit CLI Skill for Claude Code
2+
3+
This skill provides Claude Code with accurate Bit CLI command reference, eliminating trial-and-error when running bit commands.
4+
5+
## Installation
6+
7+
### Quick Install (recommended)
8+
9+
```bash
10+
# Create the skill directory
11+
mkdir -p ~/.claude/skills/bit-cli
12+
13+
# Download the skill files
14+
curl -fsL https://raw.githubusercontent.com/teambit/bit/master/contrib/claude-skill-bit-cli/SKILL.md \
15+
-o ~/.claude/skills/bit-cli/SKILL.md
16+
17+
curl -fsL https://raw.githubusercontent.com/teambit/bit/master/contrib/claude-skill-bit-cli/bit-cli-lookup \
18+
-o ~/.claude/skills/bit-cli/bit-cli-lookup
19+
20+
# Make the lookup script executable
21+
chmod +x ~/.claude/skills/bit-cli/bit-cli-lookup
22+
23+
# Download the CLI reference (or let it auto-download on first use)
24+
~/.claude/skills/bit-cli/bit-cli-lookup --update
25+
```
26+
27+
### One-liner
28+
29+
```bash
30+
mkdir -p ~/.claude/skills/bit-cli && cd ~/.claude/skills/bit-cli && curl -fsLO https://raw.githubusercontent.com/teambit/bit/master/contrib/claude-skill-bit-cli/SKILL.md && curl -fsLO https://raw.githubusercontent.com/teambit/bit/master/contrib/claude-skill-bit-cli/bit-cli-lookup && chmod +x bit-cli-lookup && ./bit-cli-lookup --update
31+
```
32+
33+
### Manual Install
34+
35+
1. Copy the following files to `~/.claude/skills/bit-cli/`:
36+
37+
- `SKILL.md`
38+
- `bit-cli-lookup`
39+
40+
2. Make the lookup script executable:
41+
42+
```bash
43+
chmod +x ~/.claude/skills/bit-cli/bit-cli-lookup
44+
```
45+
46+
3. Download the CLI reference:
47+
```bash
48+
~/.claude/skills/bit-cli/bit-cli-lookup --update
49+
```
50+
51+
## Requirements
52+
53+
- `jq` - JSON processor (install with `brew install jq` or `apt install jq`)
54+
- `curl` - For downloading updates
55+
56+
## How It Works
57+
58+
1. Claude Code automatically discovers this skill when you ask about bit commands
59+
2. Instead of loading the full 5000+-line CLI reference, Claude runs the lookup script
60+
3. The script returns only the relevant command info (~20-50 lines)
61+
4. Claude uses the accurate flags without trial-and-error
62+
63+
## Usage (for humans)
64+
65+
You can also use the lookup script directly:
66+
67+
```bash
68+
# Look up a specific command
69+
~/.claude/skills/bit-cli/bit-cli-lookup snap
70+
~/.claude/skills/bit-cli/bit-cli-lookup tag
71+
~/.claude/skills/bit-cli/bit-cli-lookup export
72+
73+
# List all commands
74+
~/.claude/skills/bit-cli/bit-cli-lookup --list
75+
76+
# Update to latest CLI reference
77+
~/.claude/skills/bit-cli/bit-cli-lookup --update
78+
```
79+
80+
## Keeping Updated
81+
82+
The CLI reference is fetched from the Bit repository. To update:
83+
84+
```bash
85+
~/.claude/skills/bit-cli/bit-cli-lookup --update
86+
```
87+
88+
## Troubleshooting
89+
90+
**"jq not found"**: Install jq with your package manager
91+
92+
**"CLI reference not found"**: Run `bit-cli-lookup --update` to download it
93+
94+
**Command not found**: Check spelling, or run `bit-cli-lookup --list` to see available commands
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: bit-cli
3+
description: Bit CLI command reference with all flags and options. Use this skill BEFORE running any bit command to get the correct syntax, flags, and arguments. Covers all bit commands including snap, tag, export, import, install, status, compile, test, add, remove, and 100+ more.
4+
---
5+
6+
# Bit CLI Reference
7+
8+
This skill provides accurate command syntax for the Bit CLI. **Always use the lookup script before running bit commands** to avoid trial-and-error with flags.
9+
10+
## Usage
11+
12+
To find the correct syntax for any bit command:
13+
14+
```bash
15+
~/.claude/skills/bit-cli/bit-cli-lookup <command-name>
16+
```
17+
18+
### Examples
19+
20+
```bash
21+
# Get snap command syntax
22+
~/.claude/skills/bit-cli/bit-cli-lookup snap
23+
24+
# Get tag command syntax
25+
~/.claude/skills/bit-cli/bit-cli-lookup tag
26+
27+
# Get export command syntax
28+
~/.claude/skills/bit-cli/bit-cli-lookup export
29+
30+
# Search for commands containing "env"
31+
~/.claude/skills/bit-cli/bit-cli-lookup env
32+
33+
# List all available commands
34+
~/.claude/skills/bit-cli/bit-cli-lookup --list
35+
```
36+
37+
## Important Notes
38+
39+
- The lookup returns the exact flags with short (`-m`) and long (`--message`) forms
40+
- Subcommands are included (e.g., `env set`, `env get`, `lane merge`)
41+
- Arguments show whether they're required `<arg>` or optional `[arg]`
42+
- Always check before using unfamiliar flags
43+
44+
## Common Commands Quick Reference
45+
46+
| Command | Description |
47+
| --------- | --------------------------------- |
48+
| `snap` | Create a snapshot (dev version) |
49+
| `tag` | Create a semver release version |
50+
| `export` | Push components to remote scope |
51+
| `import` | Pull components from remote scope |
52+
| `install` | Install dependencies |
53+
| `status` | Show workspace status |
54+
| `compile` | Compile components |
55+
| `test` | Run component tests |
56+
| `build` | Run full build pipeline |
57+
| `add` | Track new components |
58+
| `remove` | Remove components |
59+
| `lane` | Work with lanes (branches) |
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#!/usr/bin/env bash
2+
#
3+
# bit-cli-lookup - Query Bit CLI command reference
4+
# Usage: bit-cli-lookup <command-name>
5+
# bit-cli-lookup --list
6+
# bit-cli-lookup --update
7+
#
8+
9+
set -e
10+
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
CLI_REF="$SCRIPT_DIR/cli-reference.json"
13+
CLI_REF_URL="https://raw.githubusercontent.com/teambit/bit/master/scopes/harmony/cli-reference/cli-reference.json"
14+
15+
# Colors (disabled if not a terminal)
16+
if [ -t 1 ]; then
17+
BOLD='\033[1m'
18+
DIM='\033[2m'
19+
CYAN='\033[36m'
20+
GREEN='\033[32m'
21+
YELLOW='\033[33m'
22+
RESET='\033[0m'
23+
else
24+
BOLD='' DIM='' CYAN='' GREEN='' YELLOW='' RESET=''
25+
fi
26+
27+
usage() {
28+
echo "Usage: bit-cli-lookup <command-name>"
29+
echo " bit-cli-lookup --list List all commands"
30+
echo " bit-cli-lookup --update Update CLI reference from GitHub"
31+
echo ""
32+
echo "Examples:"
33+
echo " bit-cli-lookup snap"
34+
echo " bit-cli-lookup tag"
35+
echo " bit-cli-lookup lane"
36+
exit 1
37+
}
38+
39+
check_jq() {
40+
if ! command -v jq &> /dev/null; then
41+
echo "Error: jq is required but not installed."
42+
echo "Install jq using your system's package manager (e.g. 'brew install jq' on macOS or 'apt install jq' on Debian/Ubuntu)"
43+
exit 1
44+
fi
45+
}
46+
47+
check_cli_ref() {
48+
if [ ! -f "$CLI_REF" ]; then
49+
echo "CLI reference not found. Downloading..."
50+
update_cli_ref
51+
fi
52+
}
53+
54+
update_cli_ref() {
55+
echo "Updating CLI reference from GitHub..."
56+
if curl -fsL "$CLI_REF_URL" -o "$CLI_REF.tmp"; then
57+
# Validate that the downloaded file is valid JSON before replacing the existing reference
58+
if jq empty "$CLI_REF.tmp" >/dev/null 2>&1; then
59+
mv "$CLI_REF.tmp" "$CLI_REF"
60+
echo "Updated successfully."
61+
else
62+
echo "Error: Downloaded CLI reference is not valid JSON."
63+
rm -f "$CLI_REF.tmp"
64+
exit 1
65+
fi
66+
else
67+
echo "Error: Failed to download CLI reference."
68+
rm -f "$CLI_REF.tmp"
69+
exit 1
70+
fi
71+
}
72+
73+
list_commands() {
74+
echo -e "${BOLD}Available Bit Commands:${RESET}\n"
75+
jq -r '
76+
.[] |
77+
select(.private != true) |
78+
" \(.name)\(.alias | if . != "" then " (alias: \(.))" else "" end)"
79+
' "$CLI_REF" | sort
80+
}
81+
82+
format_command() {
83+
jq -r --arg cmd "$1" '
84+
def format_cmd:
85+
. as $c |
86+
"\n\u001b[1m\u001b[36mCommand: bit \(.name)\u001b[0m" +
87+
(if .alias != "" then "\n\u001b[2mAlias: \(.alias)\u001b[0m" else "" end) +
88+
"\n\n\(.description)" +
89+
(if .extendedDescription != "" then "\n\n\(.extendedDescription)" else "" end) +
90+
91+
# Arguments
92+
(if (.arguments // []) | length > 0 then
93+
"\n\n\u001b[1mArguments:\u001b[0m\n" +
94+
([.arguments[] | " \(.name): \(.description // "")"] | join("\n"))
95+
else "" end) +
96+
97+
# Options
98+
(if (.options // []) | length > 0 then
99+
"\n\n\u001b[1mOptions:\u001b[0m\n" +
100+
([.options[] |
101+
" " +
102+
(if .[0] != "" then "-\(.[0]), " else " " end) +
103+
"--\(.[1])" +
104+
(if .[2] != "" then "\n \(.[2])" else "" end)
105+
] | join("\n"))
106+
else "" end) +
107+
108+
# Examples
109+
(if (.examples // []) | length > 0 then
110+
"\n\n\u001b[1mExamples:\u001b[0m\n" +
111+
([.examples[] | " bit \(.cmd)\n \(.description)"] | join("\n"))
112+
else "" end) +
113+
114+
# Subcommands
115+
(if (.commands // []) | length > 0 then
116+
"\n\n\u001b[1mSubcommands:\u001b[0m\n" +
117+
([.commands[] | " \(.name): \(.description)"] | join("\n"))
118+
else "" end);
119+
120+
# Search for matching commands (main commands and subcommands)
121+
[
122+
# Match main commands
123+
(.[] | select(
124+
(.name | ascii_downcase | split(" ")[0]) == ($cmd | ascii_downcase) or
125+
(.name | ascii_downcase | startswith($cmd | ascii_downcase)) or
126+
(.alias | ascii_downcase) == ($cmd | ascii_downcase)
127+
)),
128+
# Match subcommands
129+
(.[] | .commands // [] | .[] | select(
130+
(.name | ascii_downcase) == ($cmd | ascii_downcase) or
131+
(.name | ascii_downcase | startswith($cmd | ascii_downcase))
132+
))
133+
] |
134+
if length == 0 then
135+
"No command found matching: \($cmd)\n\nTry: bit-cli-lookup --list"
136+
else
137+
.[] | format_cmd
138+
end
139+
' "$CLI_REF"
140+
}
141+
142+
# Main
143+
check_jq
144+
145+
case "${1:-}" in
146+
"")
147+
usage
148+
;;
149+
--help|-h)
150+
usage
151+
;;
152+
--list|-l)
153+
check_cli_ref
154+
list_commands
155+
;;
156+
--update|-u)
157+
update_cli_ref
158+
;;
159+
*)
160+
check_cli_ref
161+
format_command "$1"
162+
;;
163+
esac

0 commit comments

Comments
 (0)