Skip to content

feat: ship slash commands with GitHub Action#381

Merged
km-anthropic merged 5 commits intomainfrom
km/ship-slash-commands
Aug 4, 2025
Merged

feat: ship slash commands with GitHub Action#381
km-anthropic merged 5 commits intomainfrom
km/ship-slash-commands

Conversation

@km-anthropic
Copy link
Collaborator

Summary

  • Adds infrastructure to bundle and install slash commands with the GitHub Action
  • Includes a /code-review slash command for automated PR reviews
  • Commands are automatically copied to ~/.claude/ during action setup

Changes

  1. Created /slash-commands/ directory to store bundled commands
  2. Added /code-review command with multi-agent review logic
  3. Modified setup-claude-code-settings.ts to copy slash commands after settings setup
  4. Added test coverage for the installation process

Benefits

  • Users automatically get curated slash commands without manual installation
  • We control and can update the commands that ship with our action
  • Simple implementation - just copy files during setup
  • Enables workflows to use override_prompt: '/code-review ...'

Next Steps

  • Add configuration option to disable slash command installation
  • Consider prefix to avoid conflicts (e.g., /gh-code-review)
  • Add more slash commands for common GitHub workflows

🤖 Generated with Claude Code

- Created /slash-commands/ directory to store bundled slash commands
- Added code-review.md slash command for automated PR reviews
- Modified setup-claude-code-settings.ts to copy slash commands to ~/.claude/
- Added test coverage for slash command installation
- Commands are automatically installed when the GitHub Action runs
@claude
Copy link
Contributor

claude bot commented Aug 2, 2025

Claude finished @km-anthropic's task —— View job


PR Review: Slash Commands Infrastructure

I've completed my review of the PR that adds slash command bundling and installation infrastructure. Here's my comprehensive analysis:

Todo List

  • Read and analyze changed files
  • Review slash command implementation (/code-review)
  • Analyze setup code changes in setup-claude-code-settings.ts
  • Review test coverage additions
  • Check documentation consistency
  • Provide comprehensive feedback and suggestions

Overall Assessment

This is a well-implemented feature that adds valuable functionality by bundling and auto-installing slash commands with the GitHub Action. The implementation is clean, well-tested, and follows the project's architectural patterns.

Code Quality & Best Practices

Strong Points:

  • Clean implementation with proper error handling
  • Good test coverage including edge cases
  • Follows existing code patterns and TypeScript conventions
  • Uses path utilities properly for cross-platform compatibility
  • Appropriate use of shell redirection (2>/dev/null || true) for graceful failure handling

Architecture & Design

Good Design Decisions:

  • Simple copy-based approach that's reliable and easy to understand
  • Logical placement in setup-claude-code-settings.ts after settings configuration
  • Extensible structure - easy to add more slash commands in the future
  • Non-breaking change that doesn't affect existing functionality

Detailed Code Review

1. Slash Command Implementation (/code-review.md)

Quality: Excellent multi-agent approach with robust error handling

Strengths:

  • Well-structured 7-step process with clear responsibilities
  • Intelligent filtering system with confidence scoring (0-100 scale)
  • Prevents duplicate reviews and handles edge cases (closed PRs, drafts, etc.)
  • Good separation of concerns with parallel agent execution
  • Appropriate output formatting requirements

Minor Suggestion:

2. Setup Code Changes (setup-claude-code-settings.ts:71-84)

Quality: Clean and robust implementation

Strengths:

  • Proper path construction using path.join() for cross-platform compatibility
  • Good error handling with graceful fallback
  • Clear logging for debugging
  • Uses relative path resolution correctly with fileURLToPath and dirname

Observations:

  • Lines 73-79: The path resolution logic correctly navigates from base-action/src/ to slash-commands/
  • Line 79: The shell command cp *.md with error suppression is appropriate for this use case

3. Test Coverage (setup-claude-code-settings.test.ts:151-166)

Quality: Good coverage with realistic expectations

Strengths:

  • Tests the actual file copying functionality
  • Handles test environment limitations gracefully
  • Validates content after copying
  • Uses proper async/await patterns

Potential Issues & Suggestions

Minor Issues:

  1. Missing Agent Can this be used with a Max subscription (without an API key)? #4: The /code-review.md file lists agents Modify base action #1, Modify action name #2, Claude code manual install link is incorrect #3, and Support Max plan #5, but skips Can this be used with a Max subscription (without an API key)? #4. This should be corrected for clarity.

  2. Documentation Gap: The main README.md doesn't mention the new slash command functionality. Consider adding a brief note about bundled slash commands being automatically installed.

Enhancement Suggestions:

  1. Configuration Option: As mentioned in the PR description, consider adding an input parameter to disable slash command installation for users who prefer manual control.

  2. Collision Prevention: Consider using a prefix like gh- for bundled commands to avoid conflicts with user-installed slash commands.

  3. Version Management: Consider adding version info or timestamps to bundled commands to help with future updates.

Documentation Consistency

The current documentation doesn't mention the new slash command auto-installation feature. While not critical for this initial implementation, consider updating the README to inform users that certain slash commands come pre-installed with the action.

Security Considerations

✅ No security concerns identified. The implementation:

  • Only copies files from within the action's own directory structure
  • Uses proper path utilities to prevent directory traversal
  • Doesn't introduce any new attack vectors

Performance Impact

✅ Minimal performance impact:

  • Copy operation happens once during setup
  • File size is small (~3KB for /code-review.md)
  • Operation is logged but non-blocking

Final Recommendation

APPROVE - This is a well-crafted feature that enhances user experience without introducing risks. The implementation is solid, well-tested, and ready for deployment.

The only actionable item is fixing the missing Agent #4 in the slash command documentation, which is a minor documentation fix that doesn't affect functionality.

@km-anthropic km-anthropic requested a review from ashwin-ant August 2, 2025 15:04
- Reverted to using Bun's $ shell syntax consistently with the rest of the codebase
- Simplified slash command copying to basic shell commands
- Removed unnecessary fs/promises complexity
- Maintained all functionality and test coverage
- More appropriate for GitHub Action context where inputs are trusted
@km-anthropic km-anthropic marked this pull request as ready for review August 3, 2025 01:47
description: "Timeout in minutes for Claude Code execution"
required: false
default: "10"
slash_commands_dir:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

experimental for now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah nice catch

- Added 'experimental' prefix as suggested by Ashwin
- Updated all references in action.yml and base-action
- Restored accidentally removed code-review.md file
@km-anthropic km-anthropic merged commit 458e4b9 into main Aug 4, 2025
13 checks passed
@km-anthropic km-anthropic deleted the km/ship-slash-commands branch August 4, 2025 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants