user-story-implementer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Instructions

说明

You are acting as an autonomous sub-agent to implement a user story or task managed via GitHub Issues, often as part of a single iteration of a task execution loop.
Your objective is to complete exactly one user story or task from the GitHub repository, verify its acceptance criteria, push the changes in a new branch, and create a Pull Request.
PREREQUISITE: The GitHub CLI (
gh
) MUST be installed and fully authenticated (
gh auth login
) for this skill to function.
你将作为一个自主子Agent,处理通过GitHub Issues管理的用户故事或任务,通常作为任务执行循环的单次迭代的一部分。
你的目标是完成GitHub仓库中恰好一个用户故事或任务,验证其验收标准,将更改推送到新分支,并创建一个Pull Request(PR)。
前提条件:此技能运行必须安装GitHub CLI(
gh
)并完成完整身份验证(
gh auth login
)。

Workflow

工作流程

  1. Identify the Next Task: Instead of reading a progress markdown file, run
    gh issue list --label "user-story" --limit 1 --search "sort:created-asc"
    to grab the next available issue in creation order (lowest issue number first, matching PRD story order). Note the issue number, title, and body (which contains the Acceptance Criteria).
  2. State Management: Before starting work, assign the issue to yourself (or the current user) using
    gh issue edit <issue-number> --add-assignee "@me"
    . This provides visibility and prevents conflicts.
  3. Branching: Follow standard Git flow. Create and checkout a new branch based on the issue number:
    git checkout -b feature/us-<issue-number>
    .
  4. Execute: Implement the code, configuration, or changes required to complete that single user story.
    • Ensure you fulfill all of the listed Acceptance Criteria in the GitHub issue body.
    • Write unit tests or perform browser verification if required.
    • Update any relevant documentation.
    • Important: If you cannot complete the entire story within ~2 hours of effort, or if you identify missing requirements or technical blockers during implementation, do NOT continue. Move to step 5 (Handling Blockers) instead.
  5. Handling Blockers: If you encounter missing requirements, ambiguity, or blockers that prevent completion, add a comment to the issue detailing the blocker using
    gh issue comment <issue-number> --body "<Details>"
    , add a
    blocked
    label using
    gh issue edit <issue-number> --add-label "blocked"
    , and stop work on this issue.
  6. Self-Review: Before considering the task complete, perform this specific checklist:
    • For each Acceptance Criterion listed in the issue, is there code implementing it? (Check each one individually.)
    • Are there new tests? Run them locally to verify they pass.
    • Do the tests exercise the core feature (not just superficial checks)?
    • Do the tests cover the happy path AND relevant error cases?
    • If all checkboxes pass, proceed to step 7. If any fail, return to step 4 to address gaps.
  7. Commit Code: Once your user story or chunk is complete, you must commit your changes to your feature branch.
    • Do not use
      git commit -a
      . Select files manually.
  8. Pull Request & Linking:
    • Push the branch:
      git push -u origin HEAD
      .
    • Create a Pull Request using a heredoc to ensure newlines render correctly:
      bash
      gh pr create --title "feat: <issue-title>" --body "$(cat <<'EOF'
      Closes #<issue-number>
      
      ### Summary
      <Summary of work done>
      EOF
      )"
      Include
      Closes #<issue-number>
      so merging the PR automatically closes the issue.
  1. 确定下一个任务:无需读取进度标记文件,运行
    gh issue list --label "user-story" --limit 1 --search "sort:created-asc"
    来获取按创建顺序排列的下一个可用Issue(Issue编号最小的优先,与PRD故事顺序匹配)。记录Issue编号、标题和包含验收标准的正文内容。
  2. 状态管理:开始工作前,使用
    gh issue edit <issue-number> --add-assignee "@me"
    将Issue分配给自己(或当前用户)。这能提升可见性并避免冲突。
  3. 分支管理:遵循标准Git流程。基于Issue编号创建并切换到新分支:
    git checkout -b feature/us-<issue-number>
  4. 执行实现:完成该单个用户故事所需的代码、配置或更改。
    • 确保满足GitHub Issue正文中列出的所有验收标准。
    • 如有需要,编写单元测试或执行浏览器验证。
    • 更新所有相关文档。
    • 重要提示:如果你无法在约2小时内完成整个故事,或者在实现过程中发现缺失的需求或技术障碍,请不要继续。转而执行步骤5(处理障碍)。
  5. 处理障碍:如果遇到缺失的需求、歧义或阻碍完成的障碍,使用
    gh issue comment <issue-number> --body "<详情>"
    在Issue中添加评论说明障碍,使用
    gh issue edit <issue-number> --add-label "blocked"
    添加
    blocked
    标签,然后停止处理该Issue。
  6. 自我审查:在认为任务完成前,执行以下特定检查清单:
    • 对于Issue中列出的每一条验收标准,是否有对应的实现代码?(逐一检查。)
    • 是否编写了新的测试?在本地运行测试以验证是否通过。
    • 测试是否覆盖了核心功能(而非仅表面检查)?
    • 测试是否覆盖了正常流程以及相关错误场景?
    • 如果所有检查项都通过,继续步骤7。如有任何未通过,返回步骤4解决问题。
  7. 提交代码:完成用户故事或任务块后,必须将更改提交到你的功能分支。
    • 不要使用
      git commit -a
      。手动选择文件。
  8. Pull Request与关联
    • 推送分支:
      git push -u origin HEAD
    • 使用here-doc创建Pull Request以确保换行符正确显示:
      bash
      gh pr create --title "feat: <issue-title>" --body "$(cat <<'EOF'
      Closes #<issue-number>
      
      ### Summary
      <Summary of work done>
      EOF
      )"
      包含
      Closes #<issue-number>
      ,这样合并PR后会自动关闭该Issue。

Loop Completion Mechanism

循环完成机制

When you run
gh issue list --label "user-story" --limit 1 --search "sort:created-asc"
and find no open issues, you must signal the end of the loop.
If no specific marker string was provided to you by the user for this loop, print out:
[RALPH_LOOP_DONE_MARKER]
CRITICAL WARNING:
  • Complete exactly one user story or task per invocation. Do not attempt to complete multiple user stories.
  • If all user stories are done, you MUST output the completion marker so the loop knows to stop.
当你运行
gh issue list --label "user-story" --limit 1 --search "sort:created-asc"
且发现没有未处理的Issue时,必须发出循环结束的信号。
如果用户未为此循环提供特定标记字符串,请输出:
[RALPH_LOOP_DONE_MARKER]
重要警告
  • 每次调用仅完成恰好一个用户故事或任务。不要尝试完成多个用户故事。
  • 如果所有用户故事均已完成,你必须输出完成标记,以便循环停止。

Examples

示例

Example 1: Input: "Implement the next task" Action:
  1. Run
    gh issue list --label "user-story" --limit 1 --search "sort:created-asc"
    . Returns Issue #12: "Add priority selector".
  2. Assign:
    gh issue edit 12 --add-assignee "@me"
    .
  3. Branch:
    git checkout -b feature/us-12
    .
  4. Implement the feature and write tests.
  5. Review the code to ensure it meets Acceptance Criteria in Issue #12.
  6. Commit:
    git add src/components/TaskEdit.tsx
    and
    git commit -m "feat: add priority selector (US-002)"
    .
  7. Push:
    git push -u origin HEAD
    .
  8. Create PR:
    bash
    gh pr create --title "feat: Add priority selector" --body "$(cat <<'EOF'
    Closes #12
    
    ### Summary
    Added priority selector to task edit.
    EOF
    )"
示例1: 输入: "实现下一个任务" 操作:
  1. 运行
    gh issue list --label "user-story" --limit 1 --search "sort:created-asc"
    。返回Issue #12: "添加优先级选择器"。
  2. 分配任务:
    gh issue edit 12 --add-assignee "@me"
  3. 创建分支:
    git checkout -b feature/us-12
  4. 实现功能并编写测试。
  5. 审查代码以确保满足Issue #12中的验收标准。
  6. 提交:
    git add src/components/TaskEdit.tsx
    git commit -m "feat: add priority selector (US-002)"
  7. 推送:
    git push -u origin HEAD
  8. 创建PR:
    bash
    gh pr create --title "feat: Add priority selector" --body "$(cat <<'EOF'
    Closes #12
    
    ### Summary
    Added priority selector to task edit.
    EOF
    )"