Skip to content

Commit e4bd933

Browse files
feat: enhance claude workflow
1 parent 7373802 commit e4bd933

File tree

2 files changed

+273
-0
lines changed

2 files changed

+273
-0
lines changed
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
---
2+
name: enhance-claude-docs
3+
description: Analyze recent PR review comments and update Claude documentation files with new insights. Fetches merged, open, and closed PRs from the last N days, extracts reviewer feedback, and proposes documentation improvements. Triggers on "update claude docs", "enhance docs from PRs", "analyze PR comments".
4+
---
5+
6+
# Enhance Claude Docs
7+
8+
Analyzes PR review comments from `UiPath/uipath-typescript` and updates Claude documentation files (`CLAUDE.md`, `Agents.md`, `agent_docs/`) with documentation-worthy insights not already captured.
9+
10+
---
11+
12+
## Arguments
13+
14+
- `days_back` (positional, default: `7`) — how many days back to scan for PR activity.
15+
16+
Example invocations:
17+
- `/enhance-claude-docs` — last 7 days
18+
- `/enhance-claude-docs 14` — last 14 days
19+
20+
---
21+
22+
## Step 1: Compute Date Range
23+
24+
Compute the start date for the PR search. Handle both macOS and Linux date commands:
25+
26+
```bash
27+
# Try macOS first
28+
START_DATE=$(date -v-${DAYS_BACK}d +%Y-%m-%d 2>/dev/null) || \
29+
START_DATE=$(date -d "${DAYS_BACK} days ago" +%Y-%m-%d 2>/dev/null)
30+
END_DATE=$(date +%Y-%m-%d)
31+
```
32+
33+
Store `START_DATE` and `END_DATE` for use in the PR body later.
34+
35+
---
36+
37+
## Step 2: Fetch PRs
38+
39+
Fetch all PRs updated in the date range:
40+
41+
```bash
42+
gh api "repos/UiPath/uipath-typescript/pulls?state=all&sort=updated&direction=desc&per_page=100" \
43+
--jq "[.[] | select(.updated_at >= \"${START_DATE}\") | {number, title, state, user: .user.login, updated_at}]"
44+
```
45+
46+
If no PRs found, report "No PRs found in the last N days" and stop.
47+
48+
---
49+
50+
## Step 3: Fetch Comments for Each PR
51+
52+
For each PR, fetch both types of comments:
53+
54+
### Review comments (inline code comments)
55+
56+
```bash
57+
gh api "repos/UiPath/uipath-typescript/pulls/{pr_number}/comments" --paginate \
58+
--jq '[.[] | {id, user: .user.login, body, path, line: .original_line, created_at}]'
59+
```
60+
61+
### Conversation comments (issue-style thread comments)
62+
63+
```bash
64+
gh api "repos/UiPath/uipath-typescript/issues/{pr_number}/comments" --paginate \
65+
--jq '[.[] | {id, user: .user.login, body, created_at}]'
66+
```
67+
68+
### Filtering
69+
70+
Discard comments that match any of these:
71+
- **Bot comments**: user login ends with `[bot]`
72+
- **Too short**: body is fewer than 10 characters
73+
- **Automated**: body starts with common bot prefixes (`/`, `<!--`)
74+
75+
Collect all remaining comments with their PR context (PR number, title, state).
76+
77+
---
78+
79+
## Step 4: Read Current Documentation
80+
81+
Read all five documentation files:
82+
83+
1. `CLAUDE.md`
84+
2. `Agents.md`
85+
3. `agent_docs/architecture.md`
86+
4. `agent_docs/conventions.md`
87+
5. `agent_docs/rules.md`
88+
89+
---
90+
91+
## Step 5: Analyze Comments for Insights
92+
93+
Review each comment and determine if it contains a documentation-worthy insight. Use these criteria:
94+
95+
### Docs-worthy (act on these)
96+
97+
| Signal | Target file |
98+
|--------|-------------|
99+
| Reviewer correcting a pattern violation not yet in rules | `agent_docs/rules.md` |
100+
| Explaining WHY a convention exists or should be followed | `agent_docs/conventions.md` |
101+
| New project structure info, service patterns, or architecture decisions | `agent_docs/architecture.md` |
102+
| New commands, quick-reference items, or workflow changes | `Agents.md` |
103+
| Top-level pointers or high-level project changes (rare) | `CLAUDE.md` |
104+
105+
### Ignore (skip these)
106+
107+
- One-off bug fixes with no general lesson
108+
- Typo corrections
109+
- Insights already documented in the existing files
110+
- Unresolved debates or discussions without clear resolution
111+
- Subjective style preferences without team consensus
112+
- Comments that are questions rather than directives
113+
114+
### Deduplication
115+
116+
If multiple comments across different PRs express the same insight, consolidate into a single documentation change and cite all source PRs.
117+
118+
---
119+
120+
## Step 6: Propose and Apply Changes
121+
122+
If no actionable insights are found, report:
123+
124+
```
125+
No documentation-worthy insights found in {X} PRs with {Y} comments from {START_DATE} to {END_DATE}.
126+
```
127+
128+
And stop. Do not create a PR.
129+
130+
If actionable insights exist:
131+
132+
1. For each insight, determine the correct file and section.
133+
2. Edit the files using the Edit tool. Follow existing formatting, heading levels, and conventions in each file.
134+
3. For `agent_docs/rules.md`, add new items under the appropriate "NEVER" subsection or create a new subsection if needed. Follow the existing pattern: bold "NEVER" + action, followed by explanation with rationale.
135+
4. For `agent_docs/conventions.md`, add to the relevant section or create a new subsection following existing patterns.
136+
5. For `agent_docs/architecture.md`, update tables or sections as appropriate.
137+
6. For `Agents.md`, update the quick reference or add new sections.
138+
139+
---
140+
141+
## Step 7: Create or Update PR
142+
143+
### Check for existing PR
144+
145+
```bash
146+
gh pr list --repo UiPath/uipath-typescript --label "claude-docs-update" --state open --json number,headRefName
147+
```
148+
149+
### Ensure label exists
150+
151+
```bash
152+
gh label create "claude-docs-update" --repo UiPath/uipath-typescript --description "Auto-generated Claude docs update from PR review analysis" --color "0E8A16" 2>/dev/null || true
153+
```
154+
155+
### Branch naming
156+
157+
```bash
158+
BRANCH_NAME="claude-docs-update/$(date +%Y-%m-%d)"
159+
```
160+
161+
### If existing open PR found
162+
163+
1. Check out the existing PR branch.
164+
2. Commit changes with message: `docs: update claude docs from PR review analysis (${START_DATE} to ${END_DATE})`
165+
3. Push to the existing branch.
166+
4. Update the PR body with the new analysis using `gh pr edit`.
167+
168+
### If no existing PR
169+
170+
1. Create and check out the new branch from `main`.
171+
2. Stage and commit all changed documentation files.
172+
- Commit message: `docs: update claude docs from PR review analysis (${START_DATE} to ${END_DATE})`
173+
3. Push the branch.
174+
4. Create the PR:
175+
176+
```bash
177+
gh pr create \
178+
--repo UiPath/uipath-typescript \
179+
--title "docs: update Claude docs from PR review analysis" \
180+
--label "claude-docs-update" \
181+
--reviewer "shreyash0502" \
182+
--body "$(cat <<'EOF'
183+
## Summary
184+
Weekly analysis of PR comments ({START_DATE} -> {END_DATE}).
185+
Analyzed {X} PRs with {Y} comments. Found {Z} actionable insights.
186+
187+
## Changes
188+
### {file_path}
189+
- **{Change description}**
190+
Source: PR #{N} -- @{reviewer} commented on `{file}:{line}`:
191+
> "{original comment}"
192+
193+
### No changes
194+
- {files not modified} -- no relevant insights found
195+
196+
## PRs Analyzed
197+
| PR | Title | State | Comments |
198+
|----|-------|-------|----------|
199+
| #{N} | {title} | {state} | {count} |
200+
EOF
201+
)"
202+
```
203+
204+
**PR body rules:**
205+
- Replace all `{placeholders}` with actual values.
206+
- The **Changes** section must list every file modified with the specific change, source PR, reviewer, and original comment quote.
207+
- The **No changes** section must list files that were read but had no relevant insights.
208+
- The **PRs Analyzed** table must list every PR that was fetched, regardless of whether it yielded insights.
209+
- State values: `merged`, `open`, `closed`.
210+
211+
---
212+
213+
## Output
214+
215+
After completion, report:
216+
217+
```
218+
## Claude Docs Enhancement Summary
219+
220+
**Date range:** {START_DATE} to {END_DATE}
221+
**PRs analyzed:** {X}
222+
**Comments reviewed:** {Y}
223+
**Actionable insights:** {Z}
224+
225+
### Changes made
226+
- {file}: {brief description of changes}
227+
228+
### PR
229+
{PR URL or "No PR created -- no actionable insights found"}
230+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Claude Docs Update
2+
3+
on:
4+
schedule:
5+
- cron: '0 9 * * 1' # Every Monday at 9am UTC
6+
workflow_dispatch:
7+
inputs:
8+
days_back:
9+
description: 'Number of days to look back for PR comments'
10+
required: false
11+
default: '7'
12+
13+
jobs:
14+
enhance-docs:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
issues: write
20+
id-token: write
21+
actions: read
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Ensure label exists
30+
run: gh label create claude-docs-update --color 0E8A16 --description "Automated Claude docs enhancement" --force
31+
env:
32+
GH_TOKEN: ${{ github.token }}
33+
34+
- name: Enhance Claude docs
35+
id: claude
36+
uses: anthropics/claude-code-action@094bd24d575e7b30ac1576024817bf1a97c81262 # v1
37+
with:
38+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39+
additional_permissions: |
40+
contents: write
41+
pull-requests: write
42+
issues: write
43+
prompt: /enhance-claude-docs ${{ inputs.days_back || '7' }}

0 commit comments

Comments
 (0)