Skip to content

Conversation

@ashwin-ant
Copy link
Collaborator

When in tag mode with the SDK path, extracts the user's request from the trigger comment (text after @claude) and sends it as a separate content block. This enables the CLI to process slash commands like "/review-pr".

Changes

  • Add extract-user-request utility to parse trigger comments
  • Write user request to separate file during prompt generation
  • Send multi-block SDKUserMessage when user request file exists
  • Add tests for the extraction utility

…upport

When in tag mode with the SDK path, extracts the user's request from the
trigger comment (text after @claude) and sends it as a separate content
block. This enables the CLI to process slash commands like "/review-pr".

- Add extract-user-request utility to parse trigger comments
- Write user request to separate file during prompt generation
- Send multi-block SDKUserMessage when user request file exists
- Add tests for the extraction utility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
const promptContent = await readFile(promptPath, "utf-8");

// Check for user request file in the same directory
const userRequestPath = join(dirname(promptPath), "claude-user-request.txt");
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Quality: Magic string should be a constant

The filename "claude-user-request.txt" is hardcoded here and in src/create-prompt/index.ts:945. Define a shared constant:

export const USER_REQUEST_FILENAME = "claude-user-request.txt";


// User request file exists - create multi-block message
const userRequest = await readFile(userRequestPath, "utf-8");
console.log("Using multi-block message with user request:", userRequest);
Copy link
Contributor

Choose a reason for hiding this comment

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

Security: Sensitive data logging

User requests may contain sensitive information. Consider conditional logging based on showFullOutput to match the pattern used elsewhere in the file (line 125-129).

@claude
Copy link
Contributor

claude bot commented Jan 2, 2026

Code Review Summary

I've completed a comprehensive review of PR #785 using specialized analysis agents. Overall, the implementation is well-structured and adds valuable slash command support, but there are several critical issues that need attention.

Critical Issues

  1. 🔒 Security: ReDoS Vulnerability - The regex pattern in extract-user-request.ts:24 uses a greedy quantifier that could cause catastrophic backtracking with large inputs
  2. 🧹 Code Quality: Unused Export - extractUserRequestFromEvent() is exported but never used, creating maintenance overhead
  3. 🧪 Testing: Zero Coverage for Core Integration - createPromptConfig() and extractUserRequestFromContext() have no tests despite being critical to the feature

High Priority Issues

  1. 📝 Documentation: Missing JSDoc - extractUserRequestFromContext() lacks proper documentation
  2. 🏗️ Code Quality: Single Responsibility Violation - createPromptConfig() handles multiple concerns (file I/O, existence checking, message generation)
  3. 🔧 Code Quality: Magic String - Hardcoded filename appears in two files without a constant

Positive Observations

✅ Proper regex escaping prevents injection attacks
✅ Good null/undefined handling throughout
✅ No command injection vulnerabilities
✅ Comprehensive test coverage for the extraction utility
✅ Clear separation of concerns between extraction and usage

Performance Assessment

The changes add minimal overhead (2-5ms) and follow best practices for file I/O. No performance concerns identified.

Recommendations

Must Fix:

  • Add input length validation to prevent ReDoS
  • Remove unused extractUserRequestFromEvent function
  • Add integration tests for createPromptConfig() and extractUserRequestFromContext()

Should Fix:

  • Define shared constant for filename
  • Split createPromptConfig() into focused functions
  • Add comprehensive JSDoc for new functions

See inline comments for detailed recommendations and code examples.

- Fix potential ReDoS vulnerability by using string operations instead of regex
- Remove unused extractUserRequestFromEvent function and tests
- Extract USER_REQUEST_FILENAME to shared constants
- Conditionally log user request based on showFullOutput setting
- Add JSDoc documentation to extractUserRequestFromContext
@ashwin-ant ashwin-ant merged commit b17b541 into main Jan 3, 2026
20 checks passed
@ashwin-ant ashwin-ant deleted the feature/sdk-slash-commands branch January 3, 2026 01:57
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.

3 participants