Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:14:44 +08:00
commit fa2c495eac
13 changed files with 2330 additions and 0 deletions

284
commands/analyze_cycle.md Normal file
View File

@@ -0,0 +1,284 @@
---
description: Analyze cycle health and generate comprehensive report with actionable insights, risk analysis, capacity assessment, and specific recommendations
category: pm
tools: Task, Read, Write, TodoWrite
model: inherit
version: 1.0.0
---
# Analyze Cycle Command
Generates a comprehensive **health report** (not just data) for the current Linear cycle.
**Reports Include**:
- 🟢🟡🔴 Health assessment with overall status
- 📊 Progress metrics with data backing
- 🎯 Actionable takeaways (what needs attention NOW)
- 👥 Team capacity analysis (who can work on what)
- ⚠️ Risk identification (overweight, blocked, at-risk issues)
- 💡 Specific recommendations (what to do about it)
**Philosophy**: Provide insights and recommendations, not just data dumps. PMs should know exactly what action to take after reading the report.
## Prerequisites Check
First, verify all required tools and systems:
```bash
# 1. Validate thoughts system (REQUIRED)
if [[ -f "scripts/validate-thoughts-setup.sh" ]]; then
./scripts/validate-thoughts-setup.sh || exit 1
else
# Inline validation if script not found
if [[ ! -d "thoughts/shared" ]]; then
echo "❌ ERROR: Thoughts system not configured"
echo "Run: ./scripts/humanlayer/init-project.sh . {project-name}"
exit 1
fi
fi
# 2. Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
# 3. Check PM plugin prerequisites
if [[ -f "${SCRIPT_DIR}/check-prerequisites.sh" ]]; then
"${SCRIPT_DIR}/check-prerequisites.sh" || exit 1
else
echo "⚠️ Prerequisites check skipped (script not found at: ${SCRIPT_DIR})"
fi
```
## Process
### Step 1: Gather Configuration
```bash
# Determine script directory with fallback (if not already set)
if [[ -z "${SCRIPT_DIR}" ]]; then
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
fi
source "${SCRIPT_DIR}/pm-utils.sh"
TEAM_KEY=$(get_team_key)
CONFIG_FILE=".claude/config.json"
```
### Step 2: Spawn Research Tasks (Parallel)
Spawn multiple research agents in parallel to gather data:
**Task 1 - Get Active Cycle**:
Use Task tool with `catalyst-dev:linear-research` agent:
```
Prompt: "Get the active cycle for team ${TEAM_KEY} with all issues"
Model: haiku (fast data gathering)
```
**Task 2 - Get Team Workload**:
Use Task tool with `catalyst-dev:linear-research` agent:
```
Prompt: "List all in-progress issues for team ${TEAM_KEY}"
Model: haiku (fast data gathering)
```
**Wait for both tasks to complete**
### Step 3: Spawn Analysis Agent
Use Task tool with `cycle-analyzer` agent:
**Input**:
- Cycle data JSON from Task 1
- In-progress issues from Task 2
- Current date: $(date +%Y-%m-%d)
**Agent returns**:
Structured markdown with health assessment, risks, capacity, recommendations
### Step 4: Generate Health Report
Format the agent's analysis into a user-facing health report:
**Report Structure**:
```markdown
# Cycle Health Report: [Cycle Name]
## 🟢/🟡/🔴 Health Assessment
**Takeaway**: [One-sentence summary of cycle health and key concern]
**Current State**: [Concise statement with specific numbers]
- Progress: X% complete (Y/Z issues done)
- Time: N days remaining of M total
- Projected completion: X% (based on current velocity)
- Risk level: [Explanation]
---
## 📊 Progress Data
**Cycle**: Sprint 2025-W04 (Jan 20-26)
**Progress**: ████████░░ 45% (18/40 issues)
| Status | Count | Percentage |
|--------|-------|------------|
| ✅ Done | 18 | 45% |
| 🔄 In Progress | 12 | 30% |
| 📋 Todo | 10 | 25% |
**By Assignee**:
- Alice: 15 issues (8 done, 5 in progress, 2 todo)
- Bob: 12 issues (6 done, 4 in progress, 2 todo)
- Charlie: 8 issues (4 done, 2 in progress, 2 todo)
- Unassigned: 5 issues
---
## 👥 Team Capacity Analysis
**Available for Work**:
- Bob: 2 active issues, can take 1-2 more
- Charlie: 2 active issues, can take 1 more
**At Capacity**:
- Alice: 5 active issues (near max capacity)
**Needs Attention**:
- Dave: No active issues (assign work)
---
## ⚠️ Risks & Blockers
**🚨 Blockers** (2 issues):
- TEAM-461: External API approval (blocked 6 days)
- Owner: Alice
- Blocker: Waiting on partner team response
- TEAM-462: Dependency conflict (blocked 4 days)
- Owner: Bob
- Blocker: Upstream library bug
**⚠️ At Risk** (3 issues, >5 days in progress):
- TEAM-463: Complex refactor (7 days, Alice)
- Risk: No commits in 3 days
- TEAM-464: Database migration (6 days, Bob)
- Risk: Scope increased mid-work
- TEAM-465: API redesign (5 days, Charlie)
- Risk: Waiting on code review
---
## 💡 Recommendations
**Priority Actions** (do these today):
1. **Escalate TEAM-461** - Partner team blocking for 6 days, needs PM intervention
2. **Pair Bob with senior dev** on TEAM-462 - Dependency issue may need architectural change
3. **Check in with Alice** on TEAM-463 - 3 days no activity, may need help
**Capacity Optimization**:
1. **Assign 2 issues to Dave** from backlog (currently no active work)
2. **Assign 1 issue to Bob** once TEAM-462 unblocked (has capacity)
**Review Needed**:
1. **TEAM-464**: Scope changed mid-cycle, consider moving to next cycle
2. **TEAM-465**: Waiting on review for 2 days, expedite review process
---
## 📈 Velocity Projection
**Current Velocity**: 2.25 issues/day (18 done in 8 days)
**Remaining Work**: 22 issues
**Days Left**: 3
**Projection**: At current pace, will complete ~7 more issues = 63% total completion
**To Hit 80%**: Need to complete 14 more issues in 3 days (4.7/day) - requires addressing blockers immediately
```
### Step 5: Save Report
Write report to `thoughts/shared/reports/cycles/YYYY-MM-DD-cycle-N-status.md`
```bash
REPORT_DIR="thoughts/shared/reports/cycles"
mkdir -p "$REPORT_DIR"
REPORT_FILE="$REPORT_DIR/$(date +%Y-%m-%d)-cycle-${cycle_number}-status.md"
# Write formatted report to file
cat > "$REPORT_FILE" << EOF
# Cycle Status Report - ${cycle_name}
**Generated**: $(date +"%Y-%m-%d %H:%M")
**Cycle**: ${cycle_number} (${cycle_starts} → ${cycle_ends})
[... formatted report content ...]
EOF
echo "✅ Report saved: $REPORT_FILE"
# Update workflow context
if [[ -f "${SCRIPT_DIR}/workflow-context.sh" ]]; then
"${SCRIPT_DIR}/workflow-context.sh" add reports "$REPORT_FILE" "${TICKET_ID:-null}"
fi
```
### Step 6: Display Summary
Present concise summary to user with health assessment:
```
🟡 Cycle Health: Sprint 2025-W04 - At Risk
Takeaway: Cycle is 45% complete with 3 days remaining. We're tracking
slightly behind (projected 63% completion). Main risks: 2 blocked issues
and Dave has no assigned work.
Progress: ████████░░ 45% (18/40 issues)
Days Remaining: 3 of 10
Priority Actions:
1. Escalate TEAM-461 blocker (external dependency, 6 days)
2. Pair Bob with senior dev on TEAM-462 (dependency conflict)
3. Assign 2 backlog issues to Dave (no active work)
Status:
✅ Done: 18 | 🔄 In Progress: 12 | 📋 Todo: 10
🚨 Blocked: 2 | ⚠️ At Risk: 3 (>5 days)
Full health report: thoughts/shared/reports/cycles/2025-01-27-cycle-4-health.md
```
## Success Criteria
### Automated Verification:
- [ ] Prerequisites script passes: `./scripts/check-prerequisites.sh`
- [ ] Command executes without errors
- [ ] Report file created in expected location
- [ ] JSON parsing succeeds for all linearis output
- [ ] TodoWrite tracking works correctly
- [ ] Health assessment is data-backed
### Manual Verification:
- [ ] Health score accurately reflects cycle state
- [ ] Takeaway is clear and actionable
- [ ] Capacity analysis identifies available team members
- [ ] Recommendations are specific and prioritized
- [ ] Risk identification is meaningful
- [ ] Report guides PM to take specific action

View File

@@ -0,0 +1,195 @@
---
description: Analyze project milestone health with actionable insights, target date assessment, risk analysis, and specific recommendations
category: pm
tools: Task, Read, Write, TodoWrite
model: inherit
version: 1.0.0
---
# Analyze Milestone Command
Generates a comprehensive **health report** for a project milestone.
**Reports Include**:
- 🟢🟡🔴 Health assessment with target date feasibility
- 📊 Progress metrics toward target date
- 🎯 Actionable takeaways (what needs attention NOW)
- ⚠️ Risk identification (behind schedule, blocked, at-risk)
- 💡 Specific recommendations (adjust timeline, reduce scope, etc.)
**Philosophy**: Provide insights and recommendations for milestone planning, not just data dumps.
## Prerequisites Check
```bash
# 1. Validate thoughts system (REQUIRED)
if [[ -f "scripts/validate-thoughts-setup.sh" ]]; then
./scripts/validate-thoughts-setup.sh || exit 1
else
# Inline validation if script not found
if [[ ! -d "thoughts/shared" ]]; then
echo "❌ ERROR: Thoughts system not configured"
echo "Run: ./scripts/humanlayer/init-project.sh . {project-name}"
exit 1
fi
fi
# 2. Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
# 3. Check PM plugin prerequisites
if [[ -f "${SCRIPT_DIR}/check-prerequisites.sh" ]]; then
"${SCRIPT_DIR}/check-prerequisites.sh" || exit 1
else
echo "⚠️ Prerequisites check skipped (script not found at: ${SCRIPT_DIR})"
fi
```
## Process
### Step 1: Gather Configuration and Milestone Identifier
**Option A: User provides milestone name**
```bash
MILESTONE_NAME="Q1 Launch"
PROJECT_NAME="Mobile App"
```
**Option B: Interactive prompt**
```
Which milestone would you like to analyze?
- Milestone name: [user input]
- Project name (optional, helps scope lookup): [user input]
```
### Step 2: Spawn Research Agent
Use Task tool with `catalyst-dev:linear-research` agent:
```
Prompt: "Get milestone '${MILESTONE_NAME}' details for project '${PROJECT_NAME}' with all issues (limit 100)"
Model: haiku (fast data gathering)
```
If milestone not found or ambiguous, report error and ask user to clarify.
### Step 3: Spawn Analysis Agent
Use Task tool with `milestone-analyzer` agent:
**Input**:
- Milestone data JSON from research task
- Current date: $(date +%Y-%m-%d)
- Project configuration (if available)
**Agent returns**:
Structured markdown with:
- Health score and target date feasibility
- Progress tracking (actual vs expected)
- Risk factors (target date, blockers, at-risk)
- Issue distribution
- Specific recommendations
### Step 4: Format Report
Format the analyzer output into final report:
```markdown
# Milestone Health Report: [Milestone Name]
**Project**: [Project Name]
**Target Date**: [YYYY-MM-DD] ([X] days remaining)
**Generated**: [YYYY-MM-DD HH:MM]
---
## 🟢/🟡/🔴 Health Assessment
**Takeaway**: [One-sentence summary with target date assessment]
**Current State**:
- Progress: X% complete (Y/Z issues done)
- Target: [YYYY-MM-DD] ([N] days remaining)
- Projected completion: [YYYY-MM-DD] (based on current velocity)
- Risk level: [On track / Behind by N days / Critical]
---
## 📊 Progress Tracking
[Progress bars, velocity, time remaining]
---
## ⚠️ Risks & Blockers
[Target date risks, blockers, at-risk issues]
---
## 💡 Recommendations
[Priority-ordered actions]
---
**Next Review**: [Suggested date based on target date proximity]
```
### Step 5: Save Report
```bash
REPORT_DIR="thoughts/shared/reports/milestones"
mkdir -p "$REPORT_DIR"
# Sanitize milestone name for filename
MILESTONE_SLUG=$(echo "$MILESTONE_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
REPORT_FILE="$REPORT_DIR/$(date +%Y-%m-%d)-${MILESTONE_SLUG}.md"
# Write formatted report
# ...
echo "✅ Report saved: $REPORT_FILE"
# Update workflow context
if [[ -f "${SCRIPT_DIR}/workflow-context.sh" ]]; then
"${SCRIPT_DIR}/workflow-context.sh" add reports "$REPORT_FILE" "${TICKET_ID:-null}"
fi
```
### Step 6: Display Summary
```
🎯 Milestone Health: [Milestone Name] - [🟢/🟡/🔴]
Target Date: [YYYY-MM-DD] ([X] days remaining)
Progress: ████████░░ [X]% ([Y]/[Z] issues)
Status: [On track / Behind by N days]
Priority Actions:
1. [Action 1]
2. [Action 2]
3. [Action 3]
Full report: thoughts/shared/reports/milestones/YYYY-MM-DD-milestone.md
```
## Success Criteria
### Automated Verification:
- [ ] Research agent fetches milestone data successfully
- [ ] Analyzer agent produces structured output
- [ ] Report file created in expected location
- [ ] No errors when milestone exists
### Manual Verification:
- [ ] Health score accurately reflects milestone state
- [ ] Target date feasibility is realistic
- [ ] Recommendations are specific and actionable
- [ ] Report guides PM to adjust timeline or scope if needed
- [ ] Works with different projects and milestone names

232
commands/groom_backlog.md Normal file
View File

@@ -0,0 +1,232 @@
---
description: Groom Linear backlog to identify orphaned issues, incorrect project assignments, and health issues
category: pm
tools: Task, Read, Write
model: inherit
version: 1.0.0
---
# Groom Backlog Command
Comprehensive backlog health analysis that identifies:
- Issues without projects (orphaned)
- Issues in wrong projects (misclassified)
- Issues without estimates
- Stale issues (no activity >30 days)
- Duplicate issues (similar titles)
## Prerequisites Check
```bash
# 1. Validate thoughts system (REQUIRED)
if [[ -f "scripts/validate-thoughts-setup.sh" ]]; then
./scripts/validate-thoughts-setup.sh || exit 1
else
# Inline validation if script not found
if [[ ! -d "thoughts/shared" ]]; then
echo "❌ ERROR: Thoughts system not configured"
echo "Run: ./scripts/humanlayer/init-project.sh . {project-name}"
exit 1
fi
fi
# 2. Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
# 3. Check PM plugin prerequisites
if [[ -f "${SCRIPT_DIR}/check-prerequisites.sh" ]]; then
"${SCRIPT_DIR}/check-prerequisites.sh" || exit 1
else
echo "⚠️ Prerequisites check skipped (script not found at: ${SCRIPT_DIR})"
fi
```
## Process
### Step 1: Spawn Research Agent
```bash
# Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
source "${SCRIPT_DIR}/pm-utils.sh"
TEAM_KEY=$(get_team_key)
```
Use Task tool with `catalyst-dev:linear-research` agent:
```
Prompt: "Get all backlog issues for team ${TEAM_KEY} including issues with no cycle assignment"
Model: haiku
```
### Step 2: Spawn Analysis Agent
Use Task tool with `backlog-analyzer` agent:
**Input**: Backlog issues JSON from research
**Output**: Structured recommendations with:
- Orphaned issues (no project)
- Misplaced issues (wrong project)
- Stale issues (>30 days)
- Potential duplicates
- Missing estimates
### Step 3: Generate Grooming Report
Create markdown report with sections:
**Orphaned Issues** (no project):
```markdown
## 🏷️ Orphaned Issues (No Project Assignment)
### High Priority
- **TEAM-456**: "Add OAuth support"
- **Suggested Project**: Auth & Security
- **Reasoning**: Mentions authentication, OAuth, security tokens
- **Action**: Move to Auth project
[... more issues ...]
### Medium Priority
[... issues ...]
```
**Misplaced Issues** (wrong project):
```markdown
## 🔄 Misplaced Issues (Wrong Project)
- **TEAM-123**: "Fix dashboard bug" (currently in: API)
- **Should be in**: Frontend
- **Reasoning**: UI bug, no backend changes mentioned
- **Action**: Move to Frontend project
```
**Stale Issues** (>30 days inactive):
```markdown
## 🗓️ Stale Issues (No Activity >30 Days)
- **TEAM-789**: "Investigate caching" (last updated: 45 days ago)
- **Action**: Review and close, or assign to current cycle
```
**Duplicates** (similar titles):
```markdown
## 🔁 Potential Duplicates
- **TEAM-111**: "User authentication bug"
- **TEAM-222**: "Authentication not working"
- **Similarity**: 85%
- **Action**: Review and merge
```
**Missing Estimates**:
```markdown
## 📊 Issues Without Estimates
- TEAM-444: "Implement new feature"
- TEAM-555: "Refactor old code"
- **Action**: Add story point estimates
```
### Step 4: Interactive Review
Present recommendations and ask user:
```
📋 Backlog Grooming Report Generated
Summary:
🏷️ Orphaned: 12 issues
🔄 Misplaced: 5 issues
🗓️ Stale: 8 issues
🔁 Duplicates: 3 pairs
📊 No Estimates: 15 issues
Would you like to:
1. Review detailed report (opens in editor)
2. Apply high-confidence recommendations automatically
3. Generate Linear update commands for manual execution
4. Skip (report saved for later)
```
### Step 5: Generate Update Commands
If user chooses option 3, generate batch update script:
```bash
#!/usr/bin/env bash
# Backlog grooming updates - Generated 2025-01-27
# Move TEAM-456 to Auth project
linearis issues update TEAM-456 --project "Auth & Security"
# Move TEAM-123 to Frontend project
linearis issues update TEAM-123 --project "Frontend"
# Close stale issue TEAM-789
linearis issues update TEAM-789 --state "Canceled"
linearis comments create TEAM-789 --body "Closing stale issue (>30 days inactive)"
# [... more commands ...]
echo "✅ Backlog grooming updates applied"
```
```bash
# Save update script
UPDATE_SCRIPT="thoughts/shared/reports/backlog/$(date +%Y-%m-%d)-grooming-updates.sh"
mkdir -p "$(dirname "$UPDATE_SCRIPT")"
# [script contents saved here]
chmod +x "$UPDATE_SCRIPT"
```
### Step 6: Save Report
```bash
REPORT_DIR="thoughts/shared/reports/backlog"
mkdir -p "$REPORT_DIR"
REPORT_FILE="$REPORT_DIR/$(date +%Y-%m-%d)-backlog-grooming.md"
# Write formatted report to file
cat > "$REPORT_FILE" << EOF
# Backlog Grooming Report - $(date +%Y-%m-%d)
[... formatted report content ...]
EOF
echo "✅ Report saved: $REPORT_FILE"
# Update workflow context
if [[ -f "${SCRIPT_DIR}/workflow-context.sh" ]]; then
"${SCRIPT_DIR}/workflow-context.sh" add reports "$REPORT_FILE" null
fi
```
## Success Criteria
### Automated Verification:
- [ ] All backlog issues fetched successfully
- [ ] Agent analysis completes without errors
- [ ] Report generated with all sections
- [ ] Update script is valid bash syntax
- [ ] Files saved to correct locations
### Manual Verification:
- [ ] Orphaned issues correctly identified
- [ ] Project recommendations make sense
- [ ] Stale issues are actually inactive
- [ ] Duplicate detection has few false positives
- [ ] Report is actionable and clear

225
commands/report_daily.md Normal file
View File

@@ -0,0 +1,225 @@
---
description: Generate daily status report showing yesterday's deliveries, current work, and team members needing assignments
category: pm
tools: Task, Read, Write
model: inherit
version: 1.0.0
---
# Report Daily Command
Lightweight daily standup report for quick team status checks.
**Focus Areas**:
- ✅ What was delivered yesterday (completed issues/PRs)
- 🔄 What is the team working on RIGHT NOW (active issues)
- 👥 Who needs work assigned (no open PRs or active issues)
- ⚠️ Quick blockers/risks (issues blocked or stalled)
**Philosophy**: Fast, focused report for daily standups. Takes <30 seconds to read. No deep analysis - save that for weekly reports.
## Prerequisites Check
```bash
# 1. Validate thoughts system (REQUIRED)
if [[ -f "scripts/validate-thoughts-setup.sh" ]]; then
./scripts/validate-thoughts-setup.sh || exit 1
else
# Inline validation if script not found
if [[ ! -d "thoughts/shared" ]]; then
echo "❌ ERROR: Thoughts system not configured"
echo "Run: ./scripts/humanlayer/init-project.sh . {project-name}"
exit 1
fi
fi
# 2. Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
# 3. Check PM plugin prerequisites
if [[ -f "${SCRIPT_DIR}/check-prerequisites.sh" ]]; then
"${SCRIPT_DIR}/check-prerequisites.sh" || exit 1
else
echo "⚠️ Prerequisites check skipped (script not found at: ${SCRIPT_DIR})"
fi
```
## Process
### Step 1: Gather Configuration
```bash
# Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
source "${SCRIPT_DIR}/pm-utils.sh"
TEAM_KEY=$(get_team_key)
TODAY=$(date +%Y-%m-%d)
YESTERDAY=$(date -v-1d +%Y-%m-%d)
```
### Step 2: Spawn Research Tasks (Parallel)
Spawn 4 research agents in parallel:
**Task 1 - Yesterday's Completions**:
```
Use Task tool with catalyst-dev:linear-research agent:
Prompt: "Get issues completed yesterday for team ${TEAM_KEY} (completed after ${YESTERDAY} and before ${TODAY})"
Model: haiku
```
**Task 2 - Current In Progress**:
```
Use Task tool with catalyst-dev:linear-research agent:
Prompt: "List all in-progress issues for team ${TEAM_KEY}"
Model: haiku
```
**Task 3 - Blocked Issues**:
```
Use Task tool with catalyst-dev:linear-research agent:
Prompt: "Get all blocked issues for team ${TEAM_KEY}"
Model: haiku
```
**Task 4 - Team Members**:
```
Use Task tool with catalyst-dev:linear-research agent:
Prompt: "List all issues by assignee for team ${TEAM_KEY}"
Model: haiku
```
**Wait for all 4 research tasks to complete**
### Step 3: Analyze Results
Combine research results to identify:
- Team members with no active work
- Stalled issues (in progress >5 days, no recent updates)
- Blocker count and duration
### Step 4: Format Daily Report
```markdown
# Team Daily - [Date]
## ✅ Delivered Yesterday (${YESTERDAY})
**Issues Completed** (N):
- TEAM-456: OAuth integration (Alice)
- TEAM-457: Bug fix for login (Bob)
- TEAM-458: Update docs (Charlie)
**PRs Merged** (N):
- #123: OAuth integration → prod (Alice)
- #124: Login bug fix → prod (Bob)
---
## 🔄 Currently Working On
**Alice**:
- TEAM-461: Payment processing (in progress 3 days)
- PR #130: API refactor (in review)
**Bob**:
- TEAM-462: Database migration (in progress 1 day)
- TEAM-463: Performance optimization (in progress 2 days)
**Charlie**:
- TEAM-465: UI redesign (in progress 4 days)
---
## 👥 Available for Work
**Dave**: No active issues or PRs
**Emily**: No active issues or PRs
**Recommendation**: Assign 1-2 backlog issues to Dave and Emily
---
## ⚠️ Blockers & Quick Risks
**Blocked** (1):
- TEAM-461: Waiting on external API approval (Alice, 3 days)
**Stalled** (1):
- TEAM-465: No commits in 2 days (Charlie)
---
**Next Actions**:
1. Check in with Alice on TEAM-461 blocker status
2. Sync with Charlie on TEAM-465 progress
3. Assign work to Dave and Emily from backlog
```
### Step 5: Save Report
```bash
REPORT_DIR="thoughts/shared/reports/daily"
mkdir -p "$REPORT_DIR"
REPORT_FILE="$REPORT_DIR/$(date +%Y-%m-%d)-team-daily.md"
# Write formatted report to file
cat > "$REPORT_FILE" << EOF
# Team Daily - $(date +%Y-%m-%d)
[... formatted report content ...]
EOF
echo "✅ Report saved: $REPORT_FILE"
# Update workflow context
if [[ -f "${SCRIPT_DIR}/workflow-context.sh" ]]; then
"${SCRIPT_DIR}/workflow-context.sh" add reports "$REPORT_FILE" null
fi
```
### Step 6: Display Summary
```
📅 Team Daily - 2025-01-27
✅ Delivered yesterday: 3 issues, 2 PRs merged
🔄 In progress: 5 issues, 3 PRs open
👥 Need work: Dave, Emily (2 team members)
⚠️ Blockers: 1 issue (TEAM-461)
Quick Actions:
• Follow up on TEAM-461 blocker (Alice)
• Assign backlog work to Dave and Emily
• Check TEAM-465 status with Charlie
Full report: thoughts/shared/reports/daily/2025-01-27-team-daily.md
```
## Success Criteria
### Automated Verification:
- [ ] Data fetched from Linear and GitHub successfully
- [ ] Team member workload calculated correctly
- [ ] Report generated in under 10 seconds
- [ ] File saved to expected location
### Manual Verification:
- [ ] Yesterday's completions are accurate
- [ ] Current work assignments match reality
- [ ] Team members needing work are correctly identified
- [ ] Report is scannable in <30 seconds
- [ ] Actionable next steps are clear

225
commands/sync_prs.md Normal file
View File

@@ -0,0 +1,225 @@
---
description: Sync GitHub PRs with Linear issues and identify correlation gaps
category: pm
tools: Task, Read, Write
model: inherit
version: 1.0.0
---
# Sync PRs Command
Analyzes the relationship between GitHub pull requests and Linear issues to identify:
- PRs without linked Linear issues
- Linear issues without associated PRs
- Merged PRs with open Linear issues (candidates for closure)
- Open PRs for completed Linear issues (stale PRs)
## Prerequisites Check
```bash
# 1. Validate thoughts system (REQUIRED)
if [[ -f "scripts/validate-thoughts-setup.sh" ]]; then
./scripts/validate-thoughts-setup.sh || exit 1
else
# Inline validation if script not found
if [[ ! -d "thoughts/shared" ]]; then
echo "❌ ERROR: Thoughts system not configured"
echo "Run: ./scripts/humanlayer/init-project.sh . {project-name}"
exit 1
fi
fi
# 2. Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
# 3. Check PM plugin prerequisites
if [[ -f "${SCRIPT_DIR}/check-prerequisites.sh" ]]; then
"${SCRIPT_DIR}/check-prerequisites.sh" || exit 1
else
echo "⚠️ Prerequisites check skipped (script not found at: ${SCRIPT_DIR})"
fi
```
## Process
### Step 1: Spawn Research Tasks (Parallel)
```bash
# Determine script directory with fallback
if [[ -n "${CLAUDE_PLUGIN_ROOT}" ]]; then
SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT}/scripts"
else
# Fallback: resolve relative to this command file
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/scripts"
fi
source "${SCRIPT_DIR}/pm-utils.sh"
TEAM_KEY=$(get_team_key)
```
**Task 1 - Get GitHub PRs**:
Use `catalyst-dev:github-research` agent (if exists) or inline `gh` commands:
```
Get open and recently merged PRs (last 7 days)
```
**Task 2 - Get Linear Issues**:
Use Task tool with `catalyst-dev:linear-research` agent:
```
Prompt: "Get all in-review and in-progress issues for team ${TEAM_KEY}"
Model: haiku
```
**Wait for both tasks to complete**
### Step 2: Spawn Analysis Agent
Use Task tool with `github-linear-analyzer` agent:
**Input**:
- GitHub PRs from Task 1
- Linear issues from Task 2
**Output**:
- Linked PRs (healthy)
- Orphaned PRs (no Linear issue)
- Orphaned issues (no PR)
- Ready to close (PR merged, issue open)
- Stale PRs (>14 days)
### Step 3: Generate Sync Report
```markdown
# PR-Linear Sync Report
**Generated**: 2025-01-27
**Repository**: user/repo
**Linear Team**: TEAM
## 📊 Summary
- Open PRs: 12 (8 linked, 4 orphaned)
- Merged PRs (7d): 15 (13 linked, 2 orphaned)
- Linear issues in review: 10 (8 with PRs, 2 without)
## 🔗 Linked PRs (Healthy)
| PR | Linear Issue | Status | Author |
|----|--------------|--------|--------|
| #123 | TEAM-456 | Open | Alice |
| #124 | TEAM-457 | Merged | Bob |
## ⚠️ Orphaned PRs (No Linear Issue)
| PR | Title | Branch | Author | Action |
|----|-------|--------|--------|--------|
| #125 | "Fix bug" | fix-bug | Alice | Create Linear issue or link existing |
| #126 | "Update docs" | docs-update | Bob | Create Linear issue or link existing |
**Recommended Actions**:
```bash
# Create Linear issue for PR #125
linearis issues create \
--team TEAM \
--title "Fix bug (from PR #125)" \
--description "Imported from PR: https://github.com/user/repo/pull/125"
# Or manually link in Linear UI
```
## 🏷️ Orphaned Issues (No PR)
| Issue | Title | Status | Assignee | Action |
|-------|-------|--------|----------|--------|
| TEAM-789 | "Implement feature" | In Progress | Alice | Create PR or update status |
| TEAM-790 | "Refactor code" | In Review | Bob | PR might exist with different branch name |
## ✅ Ready to Close (PR merged, issue open)
| Issue | PR | Merged | Action |
|-------|----|--------|--------|
| TEAM-456 | #123 | 2025-01-25 | Close issue |
| TEAM-457 | #124 | 2025-01-26 | Close issue |
**Auto-close commands**:
```bash
# Update state
linearis issues update TEAM-456 --state "Done"
# Add comment
linearis comments create TEAM-456 --body "PR #123 merged: https://github.com/user/repo/pull/123"
# Update state
linearis issues update TEAM-457 --state "Done"
# Add comment
linearis comments create TEAM-457 --body "PR #124 merged: https://github.com/user/repo/pull/124"
```
## 🕐 Stale PRs (Open >14 days)
| PR | Issue | Days Open | Author | Action |
|----|-------|-----------|--------|--------|
| #120 | TEAM-450 | 18 days | Alice | Review and merge or close |
```
### Step 4: Save Report
```bash
REPORT_DIR="thoughts/shared/reports/pr-sync"
mkdir -p "$REPORT_DIR"
REPORT_FILE="$REPORT_DIR/$(date +%Y-%m-%d)-pr-sync.md"
# Write formatted report to file
cat > "$REPORT_FILE" << EOF
# PR-Linear Sync Report - $(date +%Y-%m-%d)
[... formatted report content ...]
EOF
echo "✅ Report saved: $REPORT_FILE"
# Update workflow context
if [[ -f "${SCRIPT_DIR}/workflow-context.sh" ]]; then
"${SCRIPT_DIR}/workflow-context.sh" add reports "$REPORT_FILE" null
fi
```
### Step 5: Display Summary
```
🔗 PR-Linear Sync Report
Health Score: 75/100
✅ 8 properly linked PRs
⚠️ 4 orphaned PRs need Linear issues
⚠️ 2 orphaned issues need PRs
✅ 2 ready to close
Actions available:
1. Auto-close merged issues (generates commands)
2. Create Linear issues for orphaned PRs
3. View full report
Full report: thoughts/shared/reports/pr-sync/2025-01-27-pr-sync.md
```
## Success Criteria
### Automated Verification:
- [ ] GitHub PR data fetched successfully
- [ ] Linear issue data fetched successfully
- [ ] PR-ticket correlation logic executes
- [ ] Report generated with all sections
- [ ] Auto-close commands are valid
### Manual Verification:
- [ ] PR-issue matches are accurate
- [ ] Orphaned detection has minimal false positives
- [ ] Branch name extraction works correctly
- [ ] Recommendations are actionable
- [ ] Report provides clear next steps