AgentSkillsCN

sdlc:review

创建 PR 并请求代码审查。

SKILL.md
--- frontmatter
name: sdlc:review
description: Create PR and request code review
allowed-tools:
  - Bash(git:*)
  - Bash(gh:*)
  - Grep
  - Read
  - Edit

Submit for Review

Create a commit, push to remote, create a PR, and automatically request code review.

Workflow

  1. Verify branch state - Must be on feature branch with changes
  2. Detect and remove dead code - Clean up orphaned code
  3. Stage and commit - Create informative commit message
  4. Push to remote - Ensure upstream tracking
  5. Create PR - With comprehensive description
  6. Request code review - Auto-comment with configurable review command

Step 1: Verify Branch State

bash
BASE=$(../../scripts/get-base-branch.sh)
CURRENT_BRANCH=$(git branch --show-current)

if [ "$CURRENT_BRANCH" = "$BASE" ]; then
  echo "ERROR: Cannot create PR from default branch ($BASE)"
  exit 1
fi

# Check for changes
if [ -z "$(git status --porcelain)" ]; then
  echo "No changes to commit. Nothing to submit for review."
  exit 0
fi

Step 2: Dead Code Detection

Analyze the git diff to identify removed references:

  1. Look for deleted imports, function calls, or type references
  2. Search the codebase for orphaned code (zero references)
  3. If found, delete the dead code files/functions
  4. Report what was cleaned up

Safe deletion rules:

  • Only delete code with ZERO references
  • Preserve exported members that might be used externally
  • Check both implementation and test files

Step 3: Stage and Commit

bash
git add -A

Analyze changes and generate a commit message:

  • Summarize the nature of changes (feature, fix, refactor, etc.)
  • Focus on the "why" rather than the "what"
  • Keep it concise (1-2 sentences)
bash
git commit -m "$(cat <<'EOF'
<commit message here>

Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"

Step 4: Push to Remote

bash
git push -u origin HEAD

Step 5: Create PR

Analyze all commits on the branch to create PR description:

bash
COMMIT_LOG=$(git log $BASE..HEAD --pretty=format:"- %s%n%b")

Use the commit log output to create an informative PR body. Summarize the commits into clear bullet points and generate an appropriate test plan based on what changed.

Create the PR and capture the URL:

bash
PR_URL=$(gh pr create --base $BASE --title "<PR title>" --body "$(cat <<'EOF'
## Summary

<bullet points derived from $COMMIT_LOG>

## Test Plan

<checklist based on changes made>

---
Generated with [Claude Code](https://claude.ai/code)
EOF
)")

Step 6: Request Review (Configurable)

Request review using the PR URL from Step 5. The review command is configurable via git config or environment variable:

bash
# Get review command: git config > env var > default
REVIEW_CMD=$(git config --get sdlc.review-command 2>/dev/null)
if [[ -z "$REVIEW_CMD" ]]; then
  REVIEW_CMD=${SDLC_REVIEW_COMMAND:-"/gemini review"}
fi

gh pr comment "$PR_URL" --body "$REVIEW_CMD"

Configuration options:

  • Git config: git config sdlc.review-command "/gemini review"
  • Environment variable: export SDLC_REVIEW_COMMAND="/gemini review"
  • Default: /gemini review

Output

Report success with the PR URL:

code
PR created: <PR URL>
Review requested via: <REVIEW_CMD>