nixos/shared/linked-dotfiles/opencode/skills/do-job/SKILL.md
2025-10-27 11:56:37 -06:00

341 lines
8.0 KiB
Markdown

---
name: do-job
description: Use when starting work on Jira tickets - fetches To Do tickets, creates git worktrees with proper PI-XXXXX naming, implements features using TDD (test-first), commits with ticket references, creates draft PRs, validates work with PR review, and transitions tickets through workflow to Testing
---
# Do Job
Complete developer workflow from ticket selection to validated draft PR using TDD and git worktrees.
## When to Use This Skill
Use when:
- Starting work on a new Jira ticket
- Need to set up development environment for ticket work
- Implementing features using test-driven development
- Creating PRs for Jira-tracked work
## Workflow Checklist
Copy and track progress:
```
Ticket Workflow Progress:
- [ ] Step 1: Fetch and select To Do ticket
- [ ] Step 2: Move ticket to In Progress
- [ ] Step 3: Set up git worktree
- [ ] Step 4: Write failing tests (TDD)
- [ ] Step 5: Implement feature/fix
- [ ] Step 6: Verify tests pass
- [ ] Step 7: Commit with PI-XXXXX reference
- [ ] Step 8: Push branch
- [ ] Step 9: Create draft PR
- [ ] Step 10: Review work with PR reviewer
- [ ] Step 11: Link PR to ticket
```
## Prerequisites
Verify environment:
```bash
# Check Jira access
atlassian-mcp-server_getAccessibleAtlassianResources
# Check GitHub CLI
gh auth status
# Verify in repos root directory
ls -d */
```
## Step 1: Fetch and Select Ticket
```bash
# Get To Do tickets
atlassian-mcp-server_searchJiraIssuesUsingJql \
cloudId="<cloud-id>" \
jql="assignee = currentUser() AND status = 'To Do' ORDER BY priority DESC, updated DESC" \
fields='["summary", "description", "status", "priority"]'
```
Review tickets and select one based on priority and description.
## Step 2: Move Ticket to In Progress
```bash
atlassian-mcp-server_transitionJiraIssue \
cloudId="<cloud-id>" \
issueIdOrKey="PI-XXXXX" \
transition='{"id": "41"}' # In Progress transition ID
```
Add comment explaining work start:
```bash
atlassian-mcp-server_addCommentToJiraIssue \
cloudId="<cloud-id>" \
issueIdOrKey="PI-XXXXX" \
commentBody="Starting work on this ticket using TDD approach"
```
## Step 3: Set Up Git Worktree
**CRITICAL: All branches and commits MUST include PI-XXXXX ticket number**
### Identify Repository
From repos root directory, determine which repo based on ticket description and summary.
### Create Worktree
```bash
# Navigate to develop branch of target repo
cd <repo-name>/develop
# Pull latest changes
git pull
# Create worktree with proper naming
# Pattern: ../<descriptive-name> with branch nate/PI-XXXXX_descriptive-name
git worktree add ../<descriptive-name> -b nate/PI-XXXXX_descriptive-name
# Navigate to new worktree
cd ../<descriptive-name>
```
**Naming conventions:**
- Directory: Short descriptive name (e.g., `rename-folder-fix`)
- Branch: `nate/PI-XXXXX_descriptive-name` (e.g., `nate/PI-70535_rename-folder-fix`)
- **MUST include PI-XXXXX** in branch name
## Step 4: Build Implementation Plan
Analyze ticket requirements and create TDD plan:
1. **Understand requirements** from ticket description
2. **Identify affected code** areas
3. **Plan test cases** covering:
- Happy path
- Edge cases
- Error conditions
4. **Plan implementation** approach
## Step 5: TDD Implementation
### Write Failing Tests First
**CRITICAL: Write tests BEFORE implementation**
```bash
# Identify test framework from repo
ls *_test.* test/ tests/ __tests__/
# Create or modify test file
# Write test that validates missing functionality
```
Test should:
- Clearly describe expected behavior
- Cover the specific bug/feature from ticket
- **Fail initially** (validates test is working)
### Run Failing Tests
```bash
# Verify test fails (proves test is valid)
<run-test-command>
```
Expected: Test fails with clear error showing missing functionality.
### Implement Feature/Fix
Write minimal code to make test pass:
```bash
# Implement the feature or fix
# Focus on making test pass, not perfection
```
### Run Tests Again
```bash
# Verify test now passes
<run-test-command>
```
Expected: All tests pass.
### Refactor (if needed)
Clean up implementation while keeping tests passing:
- Improve code clarity
- Remove duplication
- Follow project conventions
- **Keep tests passing**
## Step 6: Verify Complete Solution
```bash
# Run full test suite
<full-test-command>
# Run linting (if available)
<lint-command>
# Run type checking (if available)
<typecheck-command>
```
All checks must pass before proceeding.
## Step 7: Commit Changes
**CRITICAL: Commit message MUST include PI-XXXXX**
```bash
# Stage changes
git add .
# Commit with ticket reference
git commit -m "PI-XXXXX: <concise description>
<detailed explanation of changes>
- What was changed
- Why it was changed
- How it addresses the ticket"
```
**Commit message format:**
- First line: `PI-XXXXX: <summary>` (50 chars max)
- Blank line
- Detailed description explaining the why and how
- Reference ticket number (PI-XXXXX) in first line
## Step 8: Push Branch
```bash
# Push to remote
git push -u origin nate/PI-XXXXX_descriptive-name
```
## Step 9: Create Draft PR
```bash
# Create draft PR with gh CLI
gh pr create \
--draft \
--title "PI-XXXXX: <descriptive title>" \
--body "$(cat <<'PRBODY'
## Summary
- Fixes issue described in PI-XXXXX
- Implements <feature/fix> using TDD approach
## Changes
- Added tests for <functionality>
- Implemented <feature/fix>
- Verified all tests pass
## Testing
- [x] Unit tests added and passing
- [x] Linting passes
- [x] Manual testing completed
## Jira
Related ticket: PI-XXXXX
## Notes
Ready for review. Once approved, will move ticket to Pull Request status.
PRBODY
)"
```
**Save PR URL** returned by command for next steps.
## Step 10: Review Work with PR Reviewer
**CRITICAL: Invoke @pr-reviewer subagent to validate work before linking to ticket**
```bash
# Invoke the pr-reviewer subagent
@pr-reviewer please review the PR I just created
```
The pr-reviewer will:
- Verify the repository is compatible (Go with Makefile)
- Run all validation commands (tests, linting, type checking)
- Review code quality against project standards
- Check for security issues and best practices
- Provide verdict: Ready for review OR needs work
**If pr-reviewer finds issues:**
1. Address the critical issues identified
2. Re-run tests and validations
3. Commit fixes with `PI-XXXXX: Address PR review feedback`
4. Push updates
5. Invoke @pr-reviewer again to re-validate
**Only proceed to Step 11 when pr-reviewer gives approval.**
## Step 11: Link PR to Ticket
```bash
# Add PR link to Jira ticket
atlassian-mcp-server_addCommentToJiraIssue \
cloudId="<cloud-id>" \
issueIdOrKey="PI-XXXXX" \
commentBody="Draft PR created: <pr-url>
Implementation complete using TDD approach. Ready for code review."
```
## Post-Workflow Steps (Manual)
**After automated pr-reviewer approval and manual developer review:**
1. Remove draft status from PR
2. Request code review from team
3. Address any additional review comments
4. Get approval
5. **Manual:** Transition ticket to "Pull Request" status (transition ID: 381)
6. **Manual:** After merge, SDET moves to "Testing (Service Stack)" (transition ID: 201)
## Common Mistakes
### Branch Naming
-`fix-bug` (missing ticket number)
-`PI70535-fix` (missing hyphen, no username)
-`nate/PI-70535_rename-folder-fix`
### Commit Messages
-`fixed bug` (no ticket reference)
-`Updated code for PI-70535` (vague)
-`PI-70535: Fix shared folder rename permission check`
### TDD Order
- ❌ Write code first, then tests
- ❌ Skip tests entirely
- ✅ Write failing test → Implement → Verify passing → Refactor
### Worktree Location
-`git worktree add ./feature` (wrong location)
-`git worktree add ~/feature` (absolute path)
-`git worktree add ../feature-name` (parallel to develop)
## Jira Transition IDs
Reference for manual transitions:
- To Do: 11
- In Progress: 41
- Pull Request: 381
- Testing (Service Stack): 201
- Done: (varies by project)
## Reference Materials
See references/tdd-workflow.md for detailed TDD best practices.
See references/git-worktree.md for git worktree patterns and troubleshooting.