AgentSkillsCN

Implement

当用户提出“实现问题”、“为问题创建 PR”、“实现问题”时,应使用此技能。

SKILL.md
--- frontmatter
description: This skill should be used when the user asks to "implement an issue", "create a PR for issue", "implement issue #123", "turn this issue into code", or wants to implement a GitHub issue following an implementation plan and create a pull request.
argument-hint: "<issue-number>"
disable-model-invocation: true
allowed-tools: Bash, Read, Write, Edit, Grep, Glob, WebFetch

GitHub Issue Implementer

Implement a GitHub issue by reading the implementation plan from the issue (description, comments, and replies), writing the code, creating a pull request, and updating the issue status.

Workflow Overview

  1. Fetch issue details and implementation plan from GitHub
  2. Create a feature branch
  3. Implement the changes based on the plan
  4. Create a pull request
  5. Comment on the issue with PR link
  6. Add label to indicate implementation is in progress

Step 1: Fetch Issue Details

Retrieve comprehensive issue information:

bash
gh issue view $ARGUMENTS --json number,title,body,comments,labels

Parse the response to extract:

  • Issue number and title
  • Implementation plan from the body
  • Additional requirements or clarifications from comments
  • Existing labels for context

If the issue has comments, read all comments to find implementation plans or additional requirements:

bash
gh issue view $ARGUMENTS --comments

Look for implementation plan sections typically marked with headers like "Implementation Plan", "Approach", or "Steps".

Step 2: Create Feature Branch

Create and checkout a new branch for the implementation:

bash
git checkout -b issue-$ARGUMENTS

If the branch already exists, confirm with the user before proceeding.

Step 3: Implement Changes

Based on the implementation plan extracted from the issue:

  1. Analyze the plan: Identify all files to create or modify
  2. Follow the steps: Implement each step in the plan sequentially
  3. Write tests: Include unit tests as specified in the plan
  4. Follow codebase patterns: Match existing code style and conventions

During implementation:

  • Read relevant existing files to understand patterns
  • Use Grep and Glob to find related code
  • Make incremental changes, verifying each step works

If the plan is unclear or incomplete:

  • Ask the user for clarification before proceeding
  • Document assumptions made during implementation

Step 4: Create Pull Request

After implementation is complete, create a pull request:

bash
gh pr create --title "Implement #$ARGUMENTS: <issue-title>" --body "$(cat <<EOF
## Summary

Implements #$ARGUMENTS

<Brief description of changes>

## Changes Made

- <List of key changes>

## Testing

- <How the changes were tested>

## Related Issue

Closes #$ARGUMENTS

---
*Generated by Claude Code*
EOF
)"

Link the PR to the issue using "Closes #N" or "Fixes #N" syntax.

Step 5: Comment on Issue

Add a comment to the original issue linking to the PR:

bash
gh issue comment $ARGUMENTS --body "Implementation PR created: <pr-url>

The implementation follows the plan outlined in this issue. Please review the PR for details."

Step 6: Add Label

Add the implementation-started label to indicate work is in progress:

bash
gh issue edit $ARGUMENTS --add-label "implementation-started"

If the label doesn't exist, create it first:

bash
gh label create "implementation-started" --description "Implementation work has started" --color "FFA500"

Error Handling

Authentication Issues

If gh CLI is not authenticated:

code
Error: gh CLI requires authentication. Run 'gh auth login' first.

Missing Implementation Plan

If no clear implementation plan is found in the issue:

  • Inform the user that no implementation plan was found
  • Suggest using the github-issue-planner plugin first to create a plan
  • Ask if the user wants to proceed with their own implementation approach

Merge Conflicts

If there are conflicts with the base branch:

  • Report the conflicts to the user
  • Offer to help resolve them or wait for user decision

Label Creation Fails

If unable to create the label (permissions issue):

  • Continue without labeling
  • Inform the user that the label could not be added

Important Guidelines

Code Quality

  • Follow existing code patterns and conventions
  • Write clean, readable code
  • Include appropriate comments where logic is non-obvious
  • Handle edge cases mentioned in the plan

Commits

  • Make atomic commits for logical changes
  • Write clear commit messages that reference the issue number
  • Do not commit generated files or secrets

Testing

  • Run existing tests to ensure no regressions
  • Add tests as specified in the implementation plan
  • If no tests are specified, add reasonable test coverage

Communication

  • Report progress at each major step
  • Ask for clarification when requirements are ambiguous
  • Summarize what was implemented when complete

Completion Summary

After successful completion, provide a summary:

  • PR URL and number
  • List of files changed
  • Tests added or modified
  • Any deviations from the original plan
  • Next steps (code review, CI checks, etc.)