Skip to content

Commit 48c6dbc

Browse files
committed
operator slash command
1 parent 672c324 commit 48c6dbc

File tree

5 files changed

+320
-0
lines changed

5 files changed

+320
-0
lines changed

.claude/commands/README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# kubectl-operator Claude Code Slash Commands
2+
3+
This directory contains slash commands that give Claude Code awareness of the kubectl-operator plugin.
4+
5+
## Available Commands
6+
7+
### `/operator`
8+
**General help with kubectl operator plugin**
9+
10+
Use this for general questions about kubectl operator commands, workflows, and best practices.
11+
12+
**Example usage:**
13+
```
14+
/operator
15+
How do I install the prometheus operator?
16+
```
17+
18+
```
19+
/operator
20+
What's the difference between OLMv0 and OLMv1 commands?
21+
```
22+
23+
### `/operator-install`
24+
**Install a Kubernetes operator**
25+
26+
Focused helper for installing operators using `kubectl operator olmv1 install extension`.
27+
28+
**Example usage:**
29+
```
30+
/operator-install
31+
I want to install the prometheus operator
32+
```
33+
34+
```
35+
/operator-install
36+
Install cert-manager in the cert-manager namespace
37+
```
38+
39+
### `/operator-catalog`
40+
**Manage operator catalogs**
41+
42+
Helper for creating, listing, updating, and deleting ClusterCatalogs.
43+
44+
**Example usage:**
45+
```
46+
/operator-catalog
47+
Create a catalog from quay.io/operatorhubio/catalog:latest
48+
```
49+
50+
```
51+
/operator-catalog
52+
How do I check if my catalog is serving?
53+
```
54+
55+
### `/operator-debug`
56+
**Troubleshoot kubectl operator issues**
57+
58+
Debug helper that matches error messages to documented scenarios and provides fixes.
59+
60+
**Example usage:**
61+
```
62+
/operator-debug
63+
I got error: "no bundles found for package prometheus-operator"
64+
```
65+
66+
```
67+
/operator-debug
68+
My extension shows INSTALLED: False. How do I debug?
69+
```
70+
71+
## How These Work
72+
73+
Each slash command is a Markdown file that:
74+
1. Loads context about kubectl-operator
75+
2. References `olmv1.md` for accurate, up-to-date documentation
76+
3. Follows documented workflows and error scenarios
77+
4. Provides step-by-step guidance with verification
78+
79+
## Knowledge Base
80+
81+
All commands reference `olmv1.md` which contains:
82+
- Complete command syntax and flags
83+
- Prerequisites for each operation
84+
- Success verification steps
85+
- Common error scenarios and fixes
86+
- Recommended workflows
87+
- Example outputs (YAML, JSON, table formats)
88+
89+
## Customization
90+
91+
You can edit any of these `.md` files to customize the behavior. The format is:
92+
93+
```markdown
94+
---
95+
description: Short description for the command list
96+
---
97+
98+
Instructions for Claude Code...
99+
```
100+
101+
## Adding New Commands
102+
103+
Create a new `.md` file in this directory with your command name:
104+
105+
```bash
106+
.claude/commands/my-command.md
107+
```
108+
109+
Then use it in Claude Code:
110+
```
111+
/my-command
112+
```
113+
114+
## No MCP Server Required
115+
116+
These slash commands work without an MCP server - they're just Markdown files that expand into prompts. This makes them:
117+
- Easy to version control
118+
- Simple to edit
119+
- Fast to load
120+
- No dependencies to manage
121+
122+
## Documentation
123+
124+
For more on Claude Code slash commands, see:
125+
https://docs.claude.com/en/docs/claude-code/custom-commands
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
description: Manage operator catalogs using kubectl operator olmv1
3+
---
4+
5+
Help the user manage ClusterCatalogs using kubectl operator olmv1 catalog commands.
6+
7+
## Instructions
8+
9+
1. **Read the create catalog section from olmv1.md** (around line 61-258)
10+
2. **Follow the catalog workflow** from "Recommended Workflows" (around line 1240-1258)
11+
3. **Ask the user what they want to do**:
12+
- Create a new catalog
13+
- List existing catalogs
14+
- Update a catalog
15+
- Delete a catalog
16+
- Search a catalog for packages
17+
18+
4. **For catalog creation, provide the complete workflow**:
19+
```bash
20+
# Step 1: Verify catalog doesn't exist
21+
kubectl operator olmv1 get catalog <catalog-name>
22+
23+
# Step 2: Create catalog
24+
kubectl operator olmv1 create catalog <catalog-name> <image>
25+
26+
# Step 3: Poll for serving status
27+
kubectl operator olmv1 get catalog <catalog-name>
28+
29+
# Step 4: Verify packages available
30+
kubectl operator olmv1 search catalog --catalog <catalog-name>
31+
```
32+
33+
5. **Include**:
34+
- Prerequisites (image accessibility, valid FBC)
35+
- Expected success message: `catalog "<name>" created`
36+
- Polling guidance (wait for SERVING: True)
37+
- How to check conditions with yq if catalog fails to serve
38+
- Common errors and fixes from the docs
39+
40+
Now help the user with their catalog operation.

.claude/commands/operator-debug.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
description: Troubleshoot kubectl operator issues
3+
---
4+
5+
Help the user debug and troubleshoot kubectl operator issues.
6+
7+
## Instructions
8+
9+
1. **Read olmv1.md** to understand all documented error scenarios
10+
2. **Ask the user to provide**:
11+
- The command they ran
12+
- The error message they received
13+
- Output of relevant `get` commands
14+
15+
3. **Follow this diagnostic process**:
16+
17+
**For extension installation failures**:
18+
```bash
19+
# Check extension status
20+
kubectl operator olmv1 get extension <name>
21+
22+
# Check detailed conditions
23+
kubectl operator olmv1 get extension <name> -o yaml | yq eval '.status.conditions'
24+
25+
# Check catalogs are serving
26+
kubectl operator olmv1 get catalog
27+
28+
# Search for the package
29+
kubectl operator olmv1 search catalog --package <package-name>
30+
```
31+
32+
**For catalog creation failures**:
33+
```bash
34+
# Check catalog status
35+
kubectl operator olmv1 get catalog <name>
36+
37+
# Check detailed conditions
38+
kubectl operator olmv1 get catalog <name> -o yaml | yq eval '.status.conditions[] | select(.type=="Progressing")'
39+
```
40+
41+
4. **Match error messages to documented scenarios**:
42+
- Read the "Common errors" sections in olmv1.md
43+
- For install extension errors: see lines ~380-420
44+
- For create catalog errors: see lines ~237-255
45+
46+
5. **Provide**:
47+
- Root cause analysis
48+
- Specific fix from the documentation
49+
- Verification commands
50+
- Prevention tips
51+
52+
Now help the user debug their issue.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
description: Install a Kubernetes operator using kubectl operator olmv1
3+
---
4+
5+
Help the user install a Kubernetes operator using the kubectl operator olmv1 install extension command.
6+
7+
## Instructions
8+
9+
1. **Read the install extension section from olmv1.md** (around line 274-420)
10+
2. **Follow the documented workflow** from the "Recommended Workflows" section (around line 1260-1287)
11+
3. **Ask the user for required information if not provided**:
12+
- Package name (use search if they don't know it)
13+
- Namespace to install into
14+
- ServiceAccount name (default: "default")
15+
16+
4. **Provide the complete workflow**:
17+
```bash
18+
# Step 1: Search for the package
19+
kubectl operator olmv1 search catalog --package <package-name>
20+
21+
# Step 2: Verify catalogs are serving
22+
kubectl operator olmv1 get catalog
23+
24+
# Step 3: Install the extension
25+
kubectl operator olmv1 install extension <name> -n <namespace> -p <package-name>
26+
27+
# Step 4: Verify installation
28+
kubectl operator olmv1 get extension <name>
29+
```
30+
31+
5. **Include**:
32+
- Prerequisites from the docs
33+
- Expected outputs at each step
34+
- How to verify success (INSTALLED: True)
35+
- Common errors and how to fix them
36+
- Polling guidance (wait for INSTALLED: True)
37+
38+
Now help the user install their operator.

.claude/commands/operator.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
description: Help with kubectl operator plugin commands and workflows
3+
---
4+
5+
You are an expert assistant for the kubectl-operator plugin, which manages Kubernetes operators via OLM (Operator Lifecycle Manager).
6+
7+
## Your Knowledge Base
8+
9+
You have access to comprehensive documentation in `olmv1.md` which covers all olmv1 commands. When the user asks about kubectl operator commands:
10+
11+
1. **Always read olmv1.md first** to get accurate, up-to-date command syntax and examples
12+
2. **Use the documented workflows** in the "Recommended Workflows" section
13+
3. **Reference specific error scenarios** from the documentation when troubleshooting
14+
15+
## Available Commands
16+
17+
The kubectl operator plugin has two main command sets:
18+
19+
### OLMv0 Commands (Legacy)
20+
- `kubectl operator install <package>` - Install an operator (OLMv0)
21+
- `kubectl operator uninstall <package>` - Uninstall an operator
22+
- `kubectl operator list` - List installed operators
23+
- `kubectl operator list-available` - List available operators
24+
- `kubectl operator catalog add/remove/list` - Manage catalogs
25+
26+
### OLMv1 Commands (Modern)
27+
Read `olmv1.md` for complete documentation. Main commands:
28+
- `kubectl operator olmv1 create catalog` - Create a ClusterCatalog
29+
- `kubectl operator olmv1 install extension` - Install a ClusterExtension
30+
- `kubectl operator olmv1 delete catalog|extension` - Delete resources
31+
- `kubectl operator olmv1 update catalog|extension` - Update resources
32+
- `kubectl operator olmv1 get catalog|extension` - View resources
33+
- `kubectl operator olmv1 search catalog` - Search for packages
34+
35+
## How to Help
36+
37+
1. **For command help**: Read `olmv1.md` and provide the exact syntax with examples
38+
2. **For workflows**: Use the "Recommended Workflows" section from `olmv1.md`
39+
3. **For errors**: Match error messages to the "Common errors" sections and provide the documented fixes
40+
4. **For installation**: Follow the complete workflow: search → verify catalogs → install → verify
41+
5. **For catalog creation**: Include prerequisites, success verification, and polling guidance
42+
43+
## Important Guidelines
44+
45+
- **Always verify prerequisites** before suggesting commands
46+
- **Provide expected outputs** so the user knows what success looks like
47+
- **Include verification commands** after operations
48+
- **Reference specific line numbers** from olmv1.md when citing documentation
49+
- **Use the documented error scenarios** for troubleshooting
50+
- **Follow the workflows** in olmv1.md for multi-step operations
51+
52+
## Example Interaction Pattern
53+
54+
User: "How do I install the prometheus operator?"
55+
56+
Your response should:
57+
1. Read `olmv1.md` to get current install extension syntax
58+
2. Provide the complete workflow:
59+
- Search for the package first
60+
- Verify catalogs are serving
61+
- Show the install command with all required flags
62+
- Explain how to verify installation
63+
- Include common errors and fixes
64+
65+
Now, how can I help you with kubectl operator?

0 commit comments

Comments
 (0)