Skip to content

Commit 268caa3

Browse files
authored
#124 - add pr template detection to onus:pr skill (#125)
- Check for project PR templates before using generic format - Use .claude/config.json branchFormat for type inference when multiple templates - Fallback to generic format only when no templates exist
1 parent 6fdba86 commit 268caa3

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"name": "onus",
2121
"source": "./onus",
2222
"description": "Work-item automation - fetches issues, generates commits/PRs, syncs progress",
23-
"version": "0.3.3"
23+
"version": "0.3.4"
2424
}
2525
]
2626
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Session: PR Template Handling for onus:pr
2+
3+
## Details
4+
- **Issue**: #124
5+
- **Branch**: issue/feature-124/pr-template-handling
6+
- **Type**: feature
7+
- **Created**: 2026-01-14
8+
- **Status**: complete
9+
10+
## Objective
11+
Make `/onus:pr` check for project PR templates before providing the example format, ensuring project conventions are respected by default.
12+
13+
## Requirements
14+
- [x] Check for PR templates first (glob `.github/pull_request_template.md` and `.github/PULL_REQUEST_TEMPLATE/*.md`)
15+
- [x] Handle multiple templates - infer from context (session Type field, branch conventions) or ask user if ambiguous
16+
- [x] Fallback to generic format only when no project templates exist
17+
18+
## Technical Approach
19+
1. Insert "Locate PR Template" section before "Generate PR Body" in the skill
20+
2. Determine work type from branch name pattern (feature/fix/chore)
21+
3. Search for templates in priority order: type-specific → generic
22+
4. Make PR body generation conditional on template presence
23+
5. Update examples to show template detection flow
24+
25+
## Session Log
26+
27+
### 2026-01-14 - Session Started
28+
- Created branch and session file from issue #124
29+
- Issue describes problem: skill provides example format that's "complete enough" causing project templates to be skipped
30+
31+
### 2026-01-14 - Implementation Complete
32+
- Added "Locate PR Template" section with 4-step detection logic
33+
- Made "Generate PR Body" conditional (template vs fallback)
34+
- Updated example interaction to show template detection output
35+
- Added fallback example for no-template case
36+
37+
## Key Decisions
38+
- Check for templates first, only disambiguate when multiple found
39+
- Use `.claude/config.json` branchFormat for type inference (keeps onus self-contained)
40+
- Don't depend on memento session files (plugins are independent)
41+
42+
## Learnings
43+
- onus already has config.json with branchFormat - reuse existing patterns
44+
- Skill files are instructions, not code - keep them flexible, not prescriptive
45+
46+
## Files Changed
47+
- onus/commands/pr.md
48+
- onus/package.json (version bump)
49+
- onus/.claude-plugin/plugin.json (version bump)
50+
- .claude-plugin/marketplace.json (version bump)
51+
52+
## Next Steps
53+
None - implementation complete

onus/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "onus",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "Work item automation for Claude Code - auto-injected via hooks, zero config",
55
"author": {
66
"name": "David Puglielli"

onus/commands/pr.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,37 @@ Before creating the PR, verify:
4545
- `chore - lowercase description` (for chores)
4646
- No emojis, no attribution
4747

48+
### Locate PR Template
49+
50+
Before generating PR body, check for project templates:
51+
52+
1. **Check for PR templates**
53+
```bash
54+
ls .github/pull_request_template.md .github/PULL_REQUEST_TEMPLATE.md .github/PULL_REQUEST_TEMPLATE/*.md 2>/dev/null
55+
```
56+
57+
2. **Handle results**
58+
- **Single template found**: Use it as the PR body structure
59+
- **Multiple templates found**:
60+
- Parse branch name using `branchFormat` from `.claude/config.json` to determine type
61+
- Match type to template name (e.g., `feature``feature.md`)
62+
- Ask user if still ambiguous
63+
- **No templates found**: Use generic format (see fallback below)
64+
65+
3. **State the source used**
66+
- "Using project template: .github/PULL_REQUEST_TEMPLATE/feature.md"
67+
- "No project PR template found, using generic format"
68+
4869
### Generate PR Body
4970

71+
**If project template was found:**
72+
- Read the template file
73+
- Fill in template sections using session file content
74+
- Preserve all template sections (don't skip any)
75+
- Map session data: Goal → Summary, Approach → Details, Session Log → Changes
76+
77+
**If no project template (fallback):**
78+
5079
Use session file content to build the body:
5180

5281
```markdown
@@ -111,6 +140,10 @@ Branch: issue/feature-42/auth
111140
Commits: 3 commits ahead of main
112141
Session: Goal is "Add user authentication"
113142
143+
Checking for PR templates...
144+
Found: .github/PULL_REQUEST_TEMPLATE/feature.md
145+
Using project template for PR body.
146+
114147
Creating PR with title matching your commits...
115148
116149
gh pr create --title "#42 - add user authentication" --body "..."
@@ -122,6 +155,12 @@ Next steps:
122155
- Request reviewers if needed
123156
```
124157

158+
**Example without project template:**
159+
```
160+
Checking for PR templates...
161+
No project PR template found, using generic format.
162+
```
163+
125164
## Troubleshooting
126165

127166
**"Pull request already exists"?**

onus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@claude-domestique/onus",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "Work item automation plugin for Claude Code - auto-injected via hooks, zero config",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)