/kibana-dev-workflow-tools:pr-optimizerfrom kibana-dev-workflow-tools
Optimize PR size, structure, and reviewability to accelerate code review cycles.
Ships in kibana-dev-workflow-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Optimize PR size, structure, and reviewability to accelerate code review cycles.
# Get changed files and line counts
git diff --stat main...HEAD
# Detailed changes per file
git diff --shortstat main...HEAD
# Count files changed
git diff --name-only main...HEAD | wc -l
# Total LOC changed
git diff --stat main...HEAD | tail -1
Thresholds:
Action:
# Group files by directory/package
git diff --name-only main...HEAD | cut -d/ -f1-3 | sort | uniq -c
# Identify feature boundaries (look for isolated file groups)
git diff --name-only main...HEAD | grep -E "(test|spec)" # Test files
git diff --name-only main...HEAD | grep -v -E "(test|spec)" # Implementation files
# Check dependencies between changed files (import analysis)
# For each changed .ts/.tsx file, extract imports
for file in $(git diff --name-only main...HEAD | grep -E "\.(ts|tsx)$"); do
echo "=== $file ==="
grep -E "^import .* from" "$file" | grep -v "node_modules"
done
Splitting strategies:
@kbn/* packages# List commits in PR
git log --oneline main...HEAD
# Show commit sizes
git log --oneline --stat main...HEAD
# Check for fixup/WIP commits
git log --oneline main...HEAD | grep -i -E "(fixup|wip|tmp|temp)"
Good commit practices:
Suggestions:
git rebase -i main --autosquashgit reset HEAD~1 then stage incrementallygit rebase -i main# Get PR body from gh CLI
gh pr view --json body,title,labels
# Check for required sections
gh pr view --json body -q .body | grep -i "## Summary"
gh pr view --json body -q .body | grep -i "## Test Plan"
gh pr view --json body -q .body | grep -i "## Screenshots"
Quality checklist:
Template for good description:
## Summary
[Why this change? What problem does it solve?]
## Changes
- [Key change 1]
- [Key change 2]
## Test Plan
1. [Step-by-step verification]
2. [Expected outcomes]
## Screenshots
[For UI changes]
## Breaking Changes
[If any, with migration guide]
## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] Types checked locally
- [ ] Lint passed locally
# Analyze changes to suggest labels
changed_files=$(git diff --name-only main...HEAD)
# skip-ci: Only docs/comments changed
if echo "$changed_files" | grep -v -E "\.(md|txt)$" | grep -q .; then
echo "No skip-ci (code changes present)"
else
echo "Suggest: skip-ci"
fi
# documentation: Docs changed
echo "$changed_files" | grep -q "\.md$" && echo "Suggest: documentation"
# breaking: Check for breaking changes in commit messages
git log --oneline main...HEAD | grep -i "break" && echo "Suggest: breaking"
# backport: Check branch or commit messages
git log --oneline main...HEAD | grep -i "backport" && echo "Suggest: backport"
# By area (detect package changes)
echo "$changed_files" | grep -q "x-pack/platform" && echo "Suggest: Team:Platform"
echo "$changed_files" | grep -q "x-pack/solutions/security" && echo "Suggest: Team:SecuritySolution"
Calculate reviewability based on:
Score factors:
Output:
Reviewability Score: 75/100 (Good)
Strengths:
✓ Clear description with test plan
✓ Tests included
✓ Atomic commits
Improvements:
⚠ Large PR (847 LOC) - consider splitting
⚠ Mixed backend and frontend changes
Step 1: Analyze size
git diff --stat main...HEAD
# Output: 42 files changed, 847 insertions(+), 213 deletions(-)
Result: Large PR (>500 LOC, >10 files)
Step 2: Check commit organization
git log --oneline main...HEAD
# Output:
# abc123 Add new feature
# def456 Fix lint
# ghi789 WIP tests
Result: Needs cleanup (fixup commits present)
Step 3: Analyze splitting opportunities
git diff --name-only main...HEAD | cut -d/ -f1-5 | sort | uniq -c
# Output:
# 15 x-pack/platform/packages/shared/kbn-agent-builder
# 12 x-pack/platform/plugins/security_solution
# 10 docs/
# 5 x-pack/test/
Result: Can split into 3 PRs:
kbn-agent-builder changes (15 files)Step 4: Check description
gh pr view --json body -q .body
# Output: [Short description only, missing test plan]
Result: Needs improvement
Step 5: Generate recommendations
PR Optimization Report
======================
Current State:
- Size: 847 LOC, 42 files (LARGE)
- Commits: 3 (needs cleanup)
- Description: Incomplete
- Reviewability: 55/100 (Needs Improvement)
Recommendations:
1. SPLIT PR (High Priority)
Split into 3 logical PRs:
PR 1: Core agent-builder package changes
- 15 files in x-pack/platform/packages/shared/kbn-agent-builder
- ~400 LOC
- Review time: ~30 min
PR 2: Security Solution integration
- 12 files in x-pack/platform/plugins/security_solution
- ~300 LOC
- Depends on PR 1
- Review time: ~20 min
PR 3: Documentation updates
- 10 docs files
- ~150 LOC
- Can be merged independently
- Review time: ~10 min
2. CLEANUP COMMITS
Run: git rebase -i main
- Squash "Fix lint" into "Add new feature"
- Rename "WIP tests" to descriptive message
3. IMPROVE DESCRIPTION
Add missing sections:
- Test plan with verification steps
- Screenshots (for UI changes)
- Breaking changes section
4. ADD LABELS
Suggested labels:
- Team:Platform
- Team:SecuritySolution
- documentation
Actions:
Would you like me to:
a) Generate the split plan with git commands
b) Improve the PR description
c) Clean up commits
d) All of the above
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
7 skills in this plugin
/code-archaeologyUnderstand code history and context through git archaeology to answer "why", "who", and "when" questions about code./cursor-chat-browserSearch and retrieve past Cursor AI conversations across all workspaces. Use when the user asks to find a previous discussion, recall a past decision, check what was discussed before, look up prior implementations, or references "we talked about", "last time", "remember when", "previous conversation", "what did we decide". Also activates on "search conversations", "find chat", "past discussions", "conversation history".
/npx claudepluginhub patrykkopycinski/patryks-treadmill-claude-plugins --plugin kibana-dev-workflow-tools