Two Runs One Instruction
Original, raw output
Review of emergency.md Command
Issues Identified:
- Token Waste & Repeated Execution Prevention (Guideline 1 & 3)
- Line 8-10: Good addition of state management to prevent repeated runs
- However, the 5-minute cooldown may be too rigid - should check for actual code changes instead
- Unclear Parameter Handling
- Line 5: States task must fail if file missing, but doesn't specify how to handle this gracefully
- Line 29: References cat emergency.md but should use the provided argument parameter
- Test-First Approach Issues
- Lines 32-33: Good emphasis on writing tests first
- However, the instruction about "not working around the issue" needs clarification
- Should specify test file naming conventions and location structure
- Workflow Ambiguity
- Line 48: References "precommit" agent but doesn't specify if this is a Claude Code agent or external tool
- Lines 42-46: User verification step creates unnecessary back-and-forth
- SvelteKit 5 Integration Missing (Guideline 4)
- No specific guidance for SvelteKit 5 testing patterns
- Should leverage SvelteKit's built-in testing capabilities
Specific Recommendations:
- Improve State Management:
- Check git status and only proceed if there are uncommitted changes OR if emergency file has been modified since last run
- Use git log timestamp of emergency file to determine if it's been updated
- Fix Parameter Handling:
- Replace line 29 reference to hardcoded filename with proper argument usage
- Add explicit error handling for missing emergency file parameter
- Enhance Test Strategy:
- Specify that tests should use SvelteKit's @testing-library/svelte if UI components are involved
- Clarify that integration tests should hit actual endpoints using SvelteKit's test utilities
- Add naming convention: emergency-[task-name].test.ts
- Streamline Workflow:
- Remove user verification step (line 42-46) and instead automatically mark complete if tests pass
- Replace "precommit agent" reference with specific Claude Code command or bash execution
- Add automatic git commit after successful completion
- Reduce Token Usage:
- Combine similar operations (test creation + implementation) into single planning phase
- Remove redundant validation steps if tests are comprehensive
The command has good structure but needs refinement to reduce token waste, improve SvelteKit 5 integration, and eliminate ambiguous workflow steps.
Review of emergency.md Command
After analyzing the emergency.md command file, here are my specific recommendations for improvement:
1. Preventing Repeated Command Runs
Current Issue: The command has basic state management but could be more robust.
Improvements:
- Add explicit git commit hash tracking to prevent running on same state
- Check if emergency file has been modified since last run
- Add file modification timestamp checking for the emergency file itself
2. Improving Prompting for Claude Sonnet LLM
Current Issues:
- Vague instruction "Think hard about the plan" - not actionable
- Missing specific guidance on SvelteKit 5 patterns
- No clear success criteria definition
Improvements:
- Replace vague instructions with specific action items
- Add explicit requirement to use SvelteKit 5 best practices
- Define clear completion criteria before starting implementation
- Add instruction to leverage SvelteKit's built-in testing patterns
3. Token Waste Reduction
Current Issues:
- Redundant file reading (cat emergency.md when file content could be cached)
- Verbose explanatory text that could be condensed
- Missing early exit conditions
Improvements:
- Read emergency file once and cache content during command execution
- Consolidate the test implementation and task implementation steps
- Add early validation to fail fast if emergency file is malformed
- Remove redundant explanations in favor of concise action items
4. SvelteKit 5 Specific Improvements
Current Issues:
- Generic test directory assumption (tests/) - SvelteKit 5 uses different conventions
- No mention of SvelteKit-specific testing patterns or tools
- Missing integration with SvelteKit's development workflow
Improvements:
- Update test path to follow SvelteKit 5 conventions (src/lib/, src/routes/, or tests/ depending on test type)
- Add instruction to use Vitest (SvelteKit 5's default test runner) specific patterns
- Include guidance for testing SvelteKit routes, components, and server-side functionality
- Add instruction to leverage SvelteKit's $app modules for testing navigation and stores
5. Additional Command Syntax Improvements
Recommended Changes:
- Add state management section with explicit git hash and file timestamp checking
- Replace "Think hard about the plan" with "Create specific implementation plan with clear acceptance criteria"
- Consolidate test writing and implementation steps to reduce redundancy
- Add early validation for emergency file format before proceeding
- Update test directory references to be SvelteKit 5 compatible
- Add explicit instruction to use Vitest testing patterns when applicable
- Include guidance for testing SvelteKit-specific functionality (routes, components, stores)
Summary
The emergency command is well-structured but could benefit from more specific guidance, better state management to prevent repeated runs, and SvelteKit 5-specific instructions. The main improvements focus on making instructions more actionable, reducing token waste through better organization, and leveraging SvelteKit 5's conventions and strengths.