diff --git a/.claude/commands/review-translations.md b/.claude/commands/review-translations.md index 42bc2e4ea3e..8a836b51f8e 100644 --- a/.claude/commands/review-translations.md +++ b/.claude/commands/review-translations.md @@ -1,7 +1,7 @@ --- description: Review translation imports for quality issues (runs after sanitizer) -allowed-tools: Bash, Read, Glob, Grep, Task, AskUserQuestion -argument-hint: [--pr=NUMBER (auto)] [--scope=pr|full (pr)] [--language=CODE] [--model=opus|sonnet|haiku (opus)] +allowed-tools: Bash, Read, Glob, Grep, Task, Edit, AskUserQuestion +argument-hint: [--pr=NUMBER (auto)] [--scope=pr|full (pr)] [--language=CODE] [--model=opus|sonnet|haiku (opus)] [--fix] --- # Translation Review Command @@ -44,6 +44,7 @@ Reviews all files for a language when no PR context is available. | `--scope=pr\|full` | `pr` = only PR changed files, `full` = all files for languages | `pr` | | `--language=CODES` | Filter to specific language(s), comma-separated | all languages in PR | | `--model=MODEL` | Model for analysis: `opus` (deep), `sonnet` (balanced), `haiku` (fast) | `opus` | +| `--fix` | Automatically apply fixes for critical issues after review | disabled | ## Phase 0: Determine Mode and Scope diff --git a/.github/workflows/claude-review-translations.yml b/.github/workflows/claude-review-translations.yml index 0ed6351fd15..ecff942173c 100644 --- a/.github/workflows/claude-review-translations.yml +++ b/.github/workflows/claude-review-translations.yml @@ -28,6 +28,11 @@ on: - opus - sonnet - haiku + fix: + description: "Automatically fix critical translation issues" + required: false + default: false + type: boolean issue_comment: types: [created] pull_request_review_comment: @@ -95,6 +100,7 @@ jobs: echo "language_flag=" >> $GITHUB_OUTPUT echo "scope_flag=" >> $GITHUB_OUTPUT echo "model=opus" >> $GITHUB_OUTPUT + echo "fix_flag=" >> $GITHUB_OUTPUT exit 0 fi @@ -108,6 +114,12 @@ jobs: fi echo "scope_flag=--scope=${{ github.event.inputs.scope }}" >> $GITHUB_OUTPUT echo "model=${{ github.event.inputs.model }}" >> $GITHUB_OUTPUT + # Set fix_flag based on checkbox input + if [[ "${{ github.event.inputs.fix }}" == "true" ]]; then + echo "fix_flag=--fix" >> $GITHUB_OUTPUT + else + echo "fix_flag=" >> $GITHUB_OUTPUT + fi exit 0 fi @@ -134,6 +146,13 @@ jobs: echo "model=opus" >> $GITHUB_OUTPUT fi + # Extract --fix flag if present + if [[ "$COMMENT_BODY" =~ --fix ]]; then + echo "fix_flag=--fix" >> $GITHUB_OUTPUT + else + echo "fix_flag=" >> $GITHUB_OUTPUT + fi + - name: Post acknowledgment env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -145,31 +164,31 @@ jobs: - name: Run Claude Translation Review uses: anthropics/claude-code-action@v1 + timeout-minutes: 120 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - timeout_minutes: "120" - claude_args: "--model ${{ steps.parse.outputs.model }}" - # Enable Task tool for parallel language review agents (read-only + comment posting) - allowed_tools: "Task,Glob,Grep,LS,Read,Bash(git status:*),Bash(git diff:*),Bash(git log:*),Bash(git fetch:*),Bash(git worktree:*),Bash(gh api:*),Bash(gh pr view:*),Bash(gh pr comment:*)" + claude_args: | + --model ${{ steps.parse.outputs.model }} + --allowedTools "Task,Glob,Grep,LS,Read,Edit,WebFetch,Bash(git status:*),Bash(git diff:*),Bash(git log:*),Bash(git fetch:*),Bash(git worktree:*),Bash(git add:*),Bash(git commit:*),Bash(gh api:*),Bash(gh pr view:*),Bash(gh pr comment:*)" prompt: | Execute the /review-translations command for PR #${{ steps.pr.outputs.number }}. - Arguments: --pr=${{ steps.pr.outputs.number }} ${{ steps.parse.outputs.language_flag }} ${{ steps.parse.outputs.scope_flag }} + Arguments: --pr=${{ steps.pr.outputs.number }} ${{ steps.parse.outputs.language_flag }} ${{ steps.parse.outputs.scope_flag }} ${{ steps.parse.outputs.fix_flag }} Follow the instructions in .claude/commands/review-translations.md for Phase 0 (scope detection), Phase 1 (parallel agents), and Phase 2 (collecting results). IMPORTANT workflow modifications for GitHub Actions context: 1. Use parallel Task agents (ONE agent per language) as specified in the skill - 2. SKIP Phase 3 entirely (no AskUserQuestion, no interactive prompts) - this is an automated workflow - 3. After collecting results in Phase 2, post the full review report as a PR comment using: + 2. After collecting results in Phase 2, post the full review report as a PR comment using: gh pr comment ${{ steps.pr.outputs.number }} --body "..." Use a HEREDOC for the body to preserve formatting. - 4. Do NOT apply fixes automatically - just report the issues found - 5. Do NOT prompt for user input - this is fully automated - 6. If the report is very long (>60000 chars), split it into multiple comments per language - 7. At the end of your review comment, if there are critical issues, include this section: - --- - **To apply fixes**, reply with: - ``` - @claude Fix the critical brand name translation issues listed above - ``` + 3. If the report is very long (>60000 chars), split it into multiple comments per language + 4. Auto-fix behavior - check if --fix flag is present in Arguments above: + - If --fix flag IS present: After posting the review, automatically apply fixes for all critical issues found using the Edit tool (work in PR branch worktree as specified in skill). Then commit the changes. + - If --fix flag is NOT present: Do NOT apply fixes automatically - just report the issues found. At the end of your review comment, if there are critical issues, include: + --- + **To apply fixes**, reply with: + ``` + @claude /review-translations --fix + ``` + 5. Do NOT prompt for user input with AskUserQuestion - this is fully automated