Skip to content

Commit b689318

Browse files
balzssclaude
andcommitted
chore: enhance Claude Code slash commands with inst-ai integration
Add inst-ai tool integration and improve PR workflow: - Add /plan command: Generate implementation plans from Jira issues with codebase analysis - Add /ticket command: Create Jira tickets from Slack thread URLs - Update /pr command to auto-assign PRs to creator - Add commit handling: automatically use /commit for uncommitted changes - Add squashing analysis: evaluate commit history and recommend squashing when appropriate - Include guidelines for when to squash vs keep commits separate These commands streamline the workflow for analyzing issues, creating tickets, and managing pull requests while following InstUI conventions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7450ddc commit b689318

File tree

4 files changed

+329
-9
lines changed

4 files changed

+329
-9
lines changed

.claude/commands/plan.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
description: Generate implementation plan from Jira issue using inst-ai
3+
---
4+
5+
Generate a comprehensive implementation plan by analyzing Jira issues and codebase using inst-ai tool with InstUI conventions.
6+
7+
## Requirements
8+
9+
- Optional Jira issue key (e.g., INST-1234) or description
10+
- inst-ai tool must be installed globally (`npm install -g github:instructure/inst-ai-tool`)
11+
- Configuration must be set up (see inst-ai documentation)
12+
13+
## Process
14+
15+
1. **Get issue context**:
16+
17+
**If Jira issue key provided**:
18+
- Run `inst-ai jira read <issue-key> --format xml --include-comments`
19+
- Parse the issue details:
20+
- Summary and description
21+
- Acceptance criteria
22+
- Comments and discussion
23+
- **Look for entry point file paths** in description/comments (likely included by user)
24+
25+
**If plain text description provided**:
26+
- Use the description as issue context
27+
- Will need to identify entry point files manually
28+
29+
2. **Identify entry point files**:
30+
31+
**First, check if entry point is in Jira ticket**:
32+
- Look for file paths in ticket description
33+
- Check comments for mentioned components/files
34+
- Common patterns: `packages/ui-*/src/*/index.tsx`
35+
36+
**If entry point NOT found in ticket**:
37+
- **Claude Code aids file selection** (inst-ai's interactive selector doesn't work in Claude CLI)
38+
- Analyze issue context to identify relevant components
39+
- Use `Glob` tool to search for potential files:
40+
- Search component packages: `packages/ui-{component}/src/*/index.tsx`
41+
- Search by feature area based on issue description
42+
- Present 3-5 most relevant options to user
43+
- Ask user to select or provide custom path
44+
- **Pass selected file path explicitly to inst-ai**: `inst-ai plan <issue-key> -e <file-path>`
45+
46+
**Example searches**:
47+
```
48+
# For Button-related issues
49+
Glob: packages/ui-button/**/index.tsx
50+
51+
# For Select component
52+
Glob: packages/ui-select/**/index.tsx
53+
54+
# For broad changes
55+
Glob: packages/*/src/*/index.tsx
56+
```
57+
58+
3. **Scan codebase**:
59+
- Use `inst-ai scan -e <file-path> --format xml --include-docs`
60+
- Can specify multiple entry points: `-e file1.tsx file2.tsx`
61+
- Include docs to understand context: `--include-docs`
62+
- Analyze:
63+
- Component structure and dependencies
64+
- Related files and imports
65+
- Testing files
66+
- Theme files
67+
- Documentation
68+
69+
4. **Generate implementation plan**:
70+
- Combine Jira issue context with code analysis
71+
- Create structured plan with:
72+
- **Issue Summary**: What needs to be done
73+
- **Affected Components**: List of files/components to modify
74+
- **Dependencies**: Related code that may be impacted
75+
- **Implementation Steps**: Detailed, actionable tasks:
76+
1. Update component props/logic
77+
2. Update theme variables (if needed)
78+
3. Update tests
79+
4. Update documentation
80+
- **Testing Strategy**:
81+
- Unit tests (Vitest)
82+
- Component tests (Cypress)
83+
- Visual regression tests (if UI changes)
84+
- Accessibility verification
85+
- **Breaking Change Assessment**:
86+
- Evaluate if changes are breaking (see CLAUDE.md)
87+
- If breaking: document clearly with `BREAKING CHANGE:` in commit
88+
- Prefer non-breaking alternatives when possible
89+
- **Documentation Updates**:
90+
- Component README updates
91+
- API documentation
92+
- Migration guide (if breaking)
93+
94+
5. **Save session**:
95+
- Plan is automatically saved to `.inst-ai/sessions` (configured in inst-ai.config.mjs)
96+
- Session includes:
97+
- Issue context
98+
- Scanned files
99+
- Generated plan
100+
- Timestamp and metadata
101+
102+
6. **Present plan to user**:
103+
- Show complete implementation plan
104+
- Highlight breaking changes if any
105+
- List all affected files
106+
- Ask for user review and approval
107+
- **DO NOT start implementation without explicit user confirmation**
108+
109+
7. **Ready to implement**:
110+
- Once approved, work through plan step-by-step
111+
- Mark tasks as completed using TodoWrite tool
112+
- Create commits following InstUI conventions (use `/commit`)
113+
- Create PR when done (use `/pr`)
114+
115+
## Important Notes
116+
117+
- **Entry point files are critical** - they determine what code gets analyzed
118+
- **Multiple entry points are supported** - use when changes span multiple components
119+
- **inst-ai interactive mode won't work** - Claude Code must handle all file selection
120+
- **Always pass file paths explicitly** to inst-ai CLI (don't rely on interactive selector)
121+
- **Parse Jira tickets carefully** - entry points are often mentioned in descriptions/comments
122+
- **Consider dependencies** - changes may affect multiple components
123+
- **Breaking changes require extra care** - see CLAUDE.md for breaking change guidelines
124+
- **Plans are saved** - can reference later from `.inst-ai/sessions`
125+
126+
## Example Workflows
127+
128+
### With Jira issue (entry point in ticket)
129+
130+
```bash
131+
# 1. Fetch Jira issue
132+
inst-ai jira read INST-1234 --format xml --include-comments
133+
134+
# 2. Entry point found in ticket: packages/ui-button/src/Button/index.tsx
135+
# 3. Generate plan
136+
inst-ai plan INST-1234 -e packages/ui-button/src/Button/index.tsx --include-docs
137+
138+
# 4. Review plan, then implement
139+
```
140+
141+
### With Jira issue (entry point NOT in ticket)
142+
143+
```bash
144+
# 1. Fetch Jira issue
145+
inst-ai jira read INST-1234 --format xml
146+
147+
# 2. Issue is about "Button component accessibility"
148+
# 3. Claude Code searches for relevant files
149+
# Glob: packages/ui-button/**/index.tsx
150+
151+
# 4. Present options to user:
152+
# - packages/ui-button/src/Button/index.tsx
153+
# - packages/ui-button/src/Button/README.md
154+
155+
# 5. User selects: packages/ui-button/src/Button/index.tsx
156+
# 6. Generate plan
157+
inst-ai plan INST-1234 -e packages/ui-button/src/Button/index.tsx --include-docs
158+
```
159+
160+
### With plain description
161+
162+
```bash
163+
# 1. User provides: "Add dark mode support to Select component"
164+
# 2. Claude Code identifies component: ui-select
165+
# 3. Search for entry points
166+
# Glob: packages/ui-select/**/index.tsx
167+
168+
# 4. Generate plan
169+
inst-ai plan "Add dark mode support to Select component" -e packages/ui-select/src/Select/index.tsx --include-docs
170+
```
171+
172+
### Multiple entry points
173+
174+
```bash
175+
# Changes span Button and ButtonGroup
176+
inst-ai plan INST-1234 -e packages/ui-button/src/Button/index.tsx packages/ui-button/src/ButtonGroup/index.tsx --include-docs
177+
```
178+
179+
## Error Handling
180+
181+
- If Jira issue not found, verify issue key and permissions
182+
- If entry point file doesn't exist, re-search and confirm path with user
183+
- If inst-ai is not installed, provide installation instructions
184+
- If configuration is missing, direct user to run `inst-ai config validate`
185+
- If plan generation fails, check:
186+
- Entry point file is valid TypeScript/TSX
187+
- File is not too large (check token warning threshold in config)
188+
- Dependencies can be resolved
189+
190+
## InstUI-Specific Considerations
191+
192+
- **Component structure**: `/packages/ui-[name]/src/[Component]/`
193+
- **Co-located tests**: `Component.test.tsx` next to component
194+
- **Theme files**: `theme.ts` defines theme variables
195+
- **Props files**: `props.ts` defines component API
196+
- **README files**: Component documentation in component directory
197+
- **Visual regression tests**: Must add test page in `/regression-test`
198+
- **Functional components**: All new code uses hooks, never class components
199+
- **No hardcoded text**: All user-facing text from props (i18n support)

.claude/commands/pr.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,35 @@ All PRs must include:
2020

2121
## Process
2222

23-
1. Run `git status` to check current branch and remote tracking
24-
2. Run `git log master..HEAD` to see all commits that will be in the PR
25-
3. Run `git diff master...HEAD` to see full diff from base branch
26-
4. Analyze changes across ALL commits (not just latest)
27-
5. Draft PR summary covering all changes
28-
6. **If Jira ticket number is unknown, ask the user for it before creating the PR**
29-
7. Push to remote if needed: `git push -u origin <branch>`
30-
8. Create PR with `gh pr create --title "title" --body "$(cat <<'EOF'
23+
1. **Check for uncommitted changes**: Run `git status`
24+
- **If uncommitted changes exist**: Use `/commit` command to create a commit first
25+
- Ask user to confirm before creating the commit
26+
27+
2. **Analyze commit history**: Run `git log master..HEAD --oneline` to see all commits
28+
- **If no commits exist**: Inform user there are no changes to create a PR for
29+
- **If multiple commits exist**: Analyze whether they should be squashed
30+
- Squash if commits are:
31+
- Multiple small fixes/adjustments to the same feature
32+
- Follow-up commits fixing issues in previous commits (typos, lint errors, etc.)
33+
- All part of the same logical change (e.g., implementation + tests + docs)
34+
- Keep separate if commits are:
35+
- Distinct logical changes or features
36+
- Different types of work (e.g., refactoring vs new feature)
37+
- Already well-organized and clear
38+
- **If squashing is recommended**:
39+
- Present the analysis to user
40+
- Draft a single comprehensive commit message covering all changes
41+
- Ask for confirmation before squashing
42+
- Squash with: `git reset --soft master && git commit -m "$(cat <<'EOF'...EOF)"`
43+
44+
3. Run `git status` to check current branch and remote tracking
45+
4. Run `git log master..HEAD` to see all commits that will be in the PR
46+
5. Run `git diff master...HEAD` to see full diff from base branch
47+
6. Analyze changes across ALL commits (not just latest)
48+
7. Draft PR summary covering all changes
49+
8. **If Jira ticket number is unknown, ask the user for it before creating the PR**
50+
9. Push to remote if needed: `git push -u origin <branch>`
51+
10. Create PR with `gh pr create --title "title" --assignee @me --body "$(cat <<'EOF'
3152
## Summary
3253
- Bullet point 1
3354
- Bullet point 2
@@ -42,11 +63,13 @@ Fixes INST-XXXX (or omit this section if not applicable)
4263
🤖 Generated with [Claude Code](https://claude.com/claude-code)
4364
EOF
4465
)"`
45-
9. Return the PR URL
66+
11. Return the PR URL
4667

4768
**Important**:
4869
- Base branch is usually `master` (not main)
4970
- Analyze ALL commits in the branch, not just the latest one
71+
- PRs are typically squashed when merged, so having a single well-crafted commit is preferred
5072
- Use markdown checklists for test plan
5173
- Include AI attribution footer
5274
- Always confirm Jira ticket number with user if not found in commits or branch name
75+
- Always ask for user confirmation before squashing commits or creating the PR

.claude/commands/ticket.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
description: Create Jira ticket from Slack thread URL using inst-ai
3+
---
4+
5+
Create a Jira ticket from a Slack conversation using inst-ai tool with InstUI conventions.
6+
7+
## Requirements
8+
9+
- Slack thread URL is required as argument
10+
- inst-ai tool must be installed globally (`npm install -g github:instructure/inst-ai-tool`)
11+
- Configuration must be set up (see inst-ai documentation)
12+
13+
## Process
14+
15+
1. **Extract Slack conversation**:
16+
- Run `inst-ai slack "<slack-url>" --format xml --include-metadata --include-codesandbox`
17+
- This extracts the conversation in LLM-friendly XML format with full context
18+
19+
2. **Analyze the conversation**:
20+
- Parse the Slack conversation to identify:
21+
- The core issue or request
22+
- Relevant technical details
23+
- Any mentioned components or file paths
24+
- User expectations and requirements
25+
- Screenshots or CodeSandbox links
26+
27+
3. **Draft Jira ticket**:
28+
- **Summary**: Brief, clear title describing the issue (max 100 chars)
29+
- **Description**: Detailed description including:
30+
- What: Clear description of the issue/feature
31+
- Why: Context from the Slack conversation
32+
- Where: Affected components/files (if identified)
33+
- How to reproduce: Steps if it's a bug
34+
- Expected behavior: What should happen
35+
- Additional context: Links to Slack thread, screenshots, etc.
36+
- **Issue Type**: Determine appropriate type:
37+
- `Bug`: Something is broken or not working as intended
38+
- `Task`: Work that needs to be done (improvements, updates)
39+
- `Story`: New feature or functionality
40+
- **Component Detection**:
41+
- Analyze conversation for component mentions (e.g., "Button", "Select", "Modal")
42+
- Map to package paths (e.g., ui-button, ui-select)
43+
- Include in ticket description
44+
45+
4. **Use inst-ai templates**:
46+
- Templates are located in `.inst-ai/templates/jira` (configured in inst-ai.config.mjs)
47+
- Common templates: `bugReport`, `featureRequest`
48+
- Use `--template <name>` flag when appropriate
49+
- Templates ensure consistent ticket formatting
50+
51+
5. **Present draft to user**:
52+
- Show the complete ticket draft
53+
- Display summary, description, issue type, components
54+
- Ask user to confirm or request modifications
55+
- **DO NOT create ticket without explicit user confirmation**
56+
57+
6. **Create ticket**:
58+
- Once confirmed, use `inst-ai jira create` with the drafted content
59+
- If using a template: `inst-ai jira create --template bugReport --content '<json-data>'`
60+
- If custom: `inst-ai jira create --summary "..." --description "..." --type Bug`
61+
- Include link to original Slack thread in description
62+
63+
7. **Return ticket URL**:
64+
- Display the created Jira ticket URL
65+
- Confirm successful creation
66+
67+
## Important Notes
68+
69+
- **Always analyze the full Slack thread** - don't miss important context from replies
70+
- **Include Slack thread URL in ticket** - for future reference and traceability
71+
- **Component detection is optional** - skip with `--no-component-detection` for non-code issues
72+
- **Use dry-run for testing** - `inst-ai ticket "<url>" --dry-run-jira` previews without creating
73+
- **Handle CodeSandbox content** - if conversation includes CodeSandbox, extract and reference it
74+
- **Ask for clarification** - if conversation is unclear, ask user before creating ticket
75+
76+
## Example Workflow
77+
78+
```bash
79+
# Extract Slack conversation
80+
inst-ai slack "https://instructure.slack.com/archives/C123/p456" --format xml --include-metadata --include-codesandbox
81+
82+
# After analysis, create ticket with confirmation
83+
inst-ai jira create --summary "Button: Click handler not firing on mobile" \
84+
--description "Issue reported in Slack thread..." \
85+
--type Bug
86+
87+
# Or use template
88+
inst-ai jira create --template bugReport --content '{"summary":"...","description":"...","issueType":"Bug"}'
89+
```
90+
91+
## Error Handling
92+
93+
- If Slack URL is invalid or inaccessible, inform user and ask for correct URL
94+
- If inst-ai is not installed, provide installation instructions
95+
- If configuration is missing, direct user to run `inst-ai config validate`
96+
- If ticket creation fails, show error and suggest using `--dry-run-jira` to debug

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ tsconfig.build.tsbuildinfo
3131
.claude/commands/*
3232
!.claude/commands/commit.md
3333
!.claude/commands/pr.md
34+
!.claude/commands/ticket.md
35+
!.claude/commands/plan.md

0 commit comments

Comments
 (0)