Optimize slash command definitions for best practices and performance
Audit and optimize slash command definitions to follow best practices and improve performance. Use this when you've created a new command or want to review existing commands for compliance with tool groupings, size limits, and proper YAML structure.
/plugin marketplace add lpasqualis/lpclaude/plugin install lpclaude-config@lpclaude-marketplace<command-name> [--aggressive]commands/Audit and optimize the slash command /[command-name] to align with the latest best practices. Operate idempotently - if the command already adheres to all best practices, report that it's fully optimized and take no action.
$ARGUMENTS
Before making ANY changes, identify the command's essential functionality:
Parse the command name to determine the expected file path:
/command → command.md/namespace:command → namespace/command.mdSearch for the file using Glob in this order:
.claude/commands/[path] (project-local)~/.claude/commands/[path] (global)If found:
[original-path].optimizingwc -l and wc -c.optimizing copy only/, use lowercase-kebab-case, match file locationWrite without Edit, MultiEdit)[] for optional, <> for required)claude-opus-4-1)
true to exclude from SlashCommand tool
NEVER remove or replace:
Only make changes that meet ONE of these criteria:
Thresholds:
For oversized commands, RECOMMEND (don't create) splitting into focused commands.
CRITICAL: Most commands don't need parallelization. Actively REMOVE unnecessary parallelization.
Check for existing parallelization to remove:
workers/ directoryParallelization is ONLY appropriate when ALL criteria are met:
Fix these issues if found:
Consider adding disable-model-invocation: true when:
If only minor changes were made, no need to verify. Skip directly to step 8.
If and only if significant changes were made, after optimizing the working copy, run THREE identical parallel verification tasks to ensure no functionality was lost. The verifiers will compare the original with the optimized copy.
[path]/[name].md[path]/[name].md.optimizing# Set the file path for all verifiers
FILE_PATH="[full path to the command file being optimized]"
# Run THREE identical verifiers in parallel using Task tool
# Each verifier gets the EXACT SAME prompt:
prompt = """
You are an independent verification specialist. Compare the optimized copy with the original to ensure the optimization is safe and complete.
Files to compare:
- Original: $ORIGINAL_PATH
- Optimized: $OPTIMIZED_PATH
COMPREHENSIVE ANALYSIS CHECKLIST:
1. Read both versions:
- Original: Read($ORIGINAL_PATH)
- Optimized: Read($OPTIMIZED_PATH)
2. Functional Completeness:
- All WebFetch/WebSearch operations preserved
- Dynamic discovery logic intact
- Tool permissions complete (no missing tools)
- Conditional logic preserved
- Error handling maintained
- User inputs ($ARGUMENTS) preserved
- External integrations intact
- Parallelization logic preserved (if it was there originally)
3. Semantic Integrity:
- Behavioral constraints intact (must/should/never/always)
- Order dependencies preserved
- Numeric values unchanged (timeouts, limits, thresholds)
- Security requirements maintained
- Edge cases still handled
- Model selection rationale preserved
- Scope boundaries unchanged
4. Structural Validity:
- YAML syntax valid
- Required fields present
- Name matches file location
- Tools properly grouped
- No invalid command execution patterns
- Proper Task tool usage
- No hardcoded project-specific assumptions
- Valid placeholder usage
REPORT FORMAT:
## Verification Report
**Overall Status**: [PASS | FAIL | UNCERTAIN]
**Critical Issues Found** (if any):
- [List each issue that would break functionality]
**Minor Issues Found** (if any):
- [List formatting or style issues that don't affect function]
**Risk Level**: [NONE | LOW | MEDIUM | HIGH]
**Recommendation**:
[APPROVE - All critical functionality preserved]
[REJECT - Specific functionality lost: ...]
[UNCERTAIN - Need clarification on: ...]
"""
# Execute all three verifiers with this identical prompt in parallel
After receiving three reports, analyze for consensus:
iteration = 1
consensus = false
while iteration <= 5 and not consensus:
# Run 3 parallel verifications
results = [verifier1, verifier2, verifier3]
# Check consensus
if all results == PASS:
consensus = true
else:
# Analyze disagreements
issues = extract_common_issues(results)
# Adjust optimization
if critical_issues:
rollback_specific_changes(issues)
else:
refine_optimization(issues)
iteration += 1
if not consensus:
delete_optimized_copy()
report_optimization_failed()
else:
replace_original_with_optimized()
report_success()
mv [path]/[name].md.optimizing [path]/[name].mdrm [path]/[name].md.optimizing.optimizing files remain after completion## Command [Optimization Complete ✅ | Review Complete ✅]
**Command**: /[command-name]
**Status**: [Changes applied | Already compliant]
**Timestamp**: YYYY-MM-DD HH:MM:SS
### Verification Results:
- **Verifier 1**: [PASS/FAIL/UNCERTAIN]
- **Verifier 2**: [PASS/FAIL/UNCERTAIN]
- **Verifier 3**: [PASS/FAIL/UNCERTAIN]
- **Consensus**: [ACHIEVED/FAILED]
- **Iterations used**: [X of 5 maximum]
### Final Disposition:
- **Original file**: [Replaced with optimized version | Preserved unchanged]
- **Working copy**: [Promoted to original | Deleted]
### Size Analysis:
- **Line count**: [X] lines
- **Byte size**: [Y] bytes
- **Assessment**: [Status based on thresholds]
### Size Recommendations (if needed):
[Specific optimization suggestions or decomposition recommendations]
### Changes Applied (if any):
[List specific changes made]
### Compliance Status:
- ✅ Best practices compliance
- ✅ Complete tool permission groupings
- ✅ Size within limits or decomposition recommended
- ✅ Optimization timestamp added
- ✅ All verifiers passed