Skip to content

Commit 20dbcfd

Browse files
committed
feat: Enhance slash command spec with Claude Code best practices
Inspiration: https://code.claude.com/docs/en/slash-commands New frontmatter fields: - argument-hint: Show expected arguments (e.g., [pr-number] [priority]) - allowed-tools: Restrict tools for security (e.g., Bash(git:*)) - model: Specify AI model (e.g., claude-3-5-haiku for simple tasks) - Positional arguments: Support $1, $2, $3 Enhancements: - Updated all 3 templates (Pure-Execution, Script-Assisted, CLI-Referenced) - Added comprehensive frontmatter fields table - Added argument access patterns documentation - Maintained MetaSpec's Spec-Driven positioning - Preserved dual-source architecture Impact: - Better UX (users see expected args) - More secure (can restrict tools per command) - Cost-optimized (lighter models for simple tasks) - More flexible (positional arguments) - Industry standard alignment
1 parent 7d54518 commit 20dbcfd

File tree

2 files changed

+147
-1
lines changed

2 files changed

+147
-1
lines changed

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,58 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### ✨ Improvements
11+
12+
**Enhanced slash command specification with Claude Code best practices**
13+
14+
**Inspiration**: Adopted proven patterns from [Claude Code slash commands](https://code.claude.com/docs/en/slash-commands)
15+
16+
**New frontmatter fields**:
17+
1.**`argument-hint`**: Show expected arguments in `/help` (e.g., `[pr-number] [priority]`)
18+
2.**`allowed-tools`**: Restrict command to specific tools for security (e.g., `Bash(git:*), FileEdit(specs/*)`)
19+
3.**`model`**: Specify AI model for specific commands (e.g., `claude-3-5-haiku-20241022` for simple tasks)
20+
4.**Positional arguments**: Support `$1`, `$2`, `$3` in addition to `$ARGUMENTS`
21+
22+
**Enhancements**:
23+
- ✅ Updated all 3 slash command templates (Pure-Execution, Script-Assisted, CLI-Referenced)
24+
- ✅ Added comprehensive frontmatter fields table with examples
25+
- ✅ Added argument access patterns documentation
26+
- ✅ Maintained MetaSpec's unique Spec-Driven positioning
27+
- ✅ Preserved dual-source architecture (Protocol-Derived + Library-Selected)
28+
29+
**Before**:
30+
```yaml
31+
---
32+
description: Create feature spec
33+
scripts:
34+
sh: scripts/bash/script.sh
35+
---
36+
```
37+
38+
**After**:
39+
```yaml
40+
---
41+
description: Create feature specification
42+
argument-hint: [feature-description]
43+
scripts:
44+
sh: scripts/bash/script.sh --json "{ARGS}"
45+
ps: scripts/powershell/script.ps1 -Json "{ARGS}"
46+
allowed-tools: Bash(git:*), FileEdit(specs/*)
47+
model: claude-3-5-sonnet-20241022
48+
---
49+
```
50+
51+
**Impact**:
52+
-**Better UX**: Users see expected arguments in `/help`
53+
-**More secure**: Can restrict tools per command
54+
-**Cost-optimized**: Can use lighter models for simple commands
55+
-**More flexible**: Positional arguments for structured commands
56+
-**Industry standard**: Aligns with Claude Code patterns
57+
58+
**Files Changed**: `specify.md.j2`
59+
60+
---
61+
1062
### 🐛 Bug Fixes
1163

1264
**Removed hardcoded line number references**

src/metaspec/templates/meta/sdd/commands/specify.md.j2

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,35 @@ api-toolkit lint openapi.yaml
578578

579579
---
580580

581+
### 📋 Frontmatter Fields (YAML Metadata)
582+
583+
All slash commands support frontmatter metadata (inspired by [Claude Code slash commands](https://code.claude.com/docs/en/slash-commands)):
584+
585+
| Field | Required | Description | Example |
586+
|-------|----------|-------------|---------|
587+
| `description` | ✅ Yes | Brief description (shown in `/help`) | `"Create feature specification"` |
588+
| `argument-hint` | ⚠️ Recommended | Show expected arguments | `[feature-description]` or `[pr-number] [priority]` |
589+
| `scripts` | Optional | Cross-platform scripts | `sh: scripts/bash/script.sh`<br>`ps: scripts/powershell/script.ps1` |
590+
| `allowed-tools` | Optional | Restrict tools (security) | `Bash(git:*), FileEdit(specs/*)` |
591+
| `model` | Optional | Specify AI model | `claude-3-5-sonnet-20241022` |
592+
593+
**Argument Access Patterns**:
594+
- `$ARGUMENTS` - All arguments as single string (e.g., "arg1 arg2 arg3")
595+
- `$1`, `$2`, `$3` - Individual positional arguments (like shell scripts)
596+
- `{ARGS}` - Escaped for safe script execution
597+
598+
**Example frontmatter**:
599+
\```yaml
600+
---
601+
description: Review pull request with priority
602+
argument-hint: [pr-number] [priority] [assignee]
603+
allowed-tools: Bash(git:*), FileEdit(docs/*)
604+
model: claude-3-5-sonnet-20241022
605+
---
606+
\```
607+
608+
---
609+
581610
### 🎯 Dual-Source Architecture (Composable Spec Systems)
582611

583612
**IMPORTANT**: Slash Commands come from **TWO sources** and can be **composed**:
@@ -942,8 +971,27 @@ Based on your toolkit functions (from **Component 3, STEP 1: Define Toolkit Type
942971
##### Template 1: Pure-Execution Slash Commands (Most Common)
943972

944973
```markdown
974+
---
975+
description: Brief description of what this command does
976+
argument-hint: [arg1] [arg2] # Optional: show expected arguments
977+
allowed-tools: Bash(git:*), FileEdit(specs/*) # Optional: restrict tools
978+
model: claude-3-5-sonnet-20241022 # Optional: specify model
979+
---
980+
945981
# /{toolkit-name}.{command}
946982

983+
## User Input
984+
985+
\```text
986+
$ARGUMENTS
987+
\```
988+
989+
You **MUST** consider the user input before proceeding (if not empty).
990+
991+
**Argument Access**:
992+
- `$ARGUMENTS` - All arguments as single string
993+
- `$1`, `$2`, `$3` - Individual positional arguments
994+
947995
## Purpose
948996
[What protocol-compliant output to produce]
949997

@@ -1005,14 +1053,43 @@ User can validate output independently:
10051053
##### Template 2: Script-Assisted Slash Commands (Spec-Kit Pattern)
10061054

10071055
```markdown
1056+
---
1057+
description: Brief description of what this command does
1058+
argument-hint: [arg1] [arg2] # Optional: show expected arguments
1059+
scripts:
1060+
sh: scripts/bash/{script-name}.sh --json "{ARGS}"
1061+
ps: scripts/powershell/{script-name}.ps1 -Json "{ARGS}"
1062+
allowed-tools: Bash(*), FileEdit(*) # Scripts need broader permissions
1063+
model: claude-3-5-sonnet-20241022 # Optional: specify model
1064+
---
1065+
10081066
# /{toolkit-name}.{command}
10091067

1068+
## User Input
1069+
1070+
\```text
1071+
$ARGUMENTS
1072+
\```
1073+
1074+
You **MUST** consider the user input before proceeding (if not empty).
1075+
1076+
**Argument Access**:
1077+
- `$ARGUMENTS` - All arguments as single string
1078+
- `$1`, `$2`, `$3` - Individual positional arguments
1079+
- `{ARGS}` - Escaped for script execution
1080+
10101081
## Purpose
10111082
[What to produce, with script handling setup]
10121083

10131084
## Helper Script
1085+
1086+
**Cross-platform execution**:
10141087
\```bash
1015-
scripts/{script-name}.sh --args
1088+
# Linux/Mac
1089+
scripts/bash/{script-name}.sh --json "$ARGUMENTS"
1090+
1091+
# Windows
1092+
scripts/powershell/{script-name}.ps1 -Json "$ARGUMENTS"
10161093
\```
10171094

10181095
**Script Purpose**: Set up file structure, create skeleton
@@ -1056,8 +1133,25 @@ scripts/{script-name}.sh --args
10561133
**Purpose**: Remind AI to suggest CLI validation after production
10571134

10581135
```markdown
1136+
---
1137+
description: Validate output against protocol specifications
1138+
argument-hint: [file-to-validate] # Optional: show expected arguments
1139+
allowed-tools: Bash({toolkit-name}:validate:*) # Only allow validation tools
1140+
model: claude-3-5-haiku-20241022 # Can use lighter model for simple reminders
1141+
---
1142+
10591143
# /{toolkit-name}.validate
10601144

1145+
## User Input
1146+
1147+
\```text
1148+
$ARGUMENTS
1149+
\```
1150+
1151+
**Argument Access**:
1152+
- `$1` - File to validate (if provided)
1153+
- `$ARGUMENTS` - All arguments
1154+
10611155
## Purpose
10621156
Remind AI to suggest validation after producing content
10631157

0 commit comments

Comments
 (0)