Skip to content

Commit 8023fbe

Browse files
feat: add enhance-claude-docs skill and weekly workflow (#351)
* feat: enhance claude workflow * fix: graphQL for comment analysis
1 parent 8849865 commit 8023fbe

2 files changed

Lines changed: 312 additions & 0 deletions

File tree

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
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 Review Threads via GraphQL
51+
52+
Use GitHub's GraphQL API to fetch **review threads** (not individual comments) for each PR. This gives us thread resolution status and the full conversation in one call.
53+
54+
### GraphQL query (batch per PR)
55+
56+
```bash
57+
gh api graphql -f query='
58+
{
59+
repository(owner: "UiPath", name: "uipath-typescript") {
60+
pullRequest(number: {pr_number}) {
61+
title
62+
state
63+
author { login }
64+
reviewThreads(first: 100) {
65+
nodes {
66+
isResolved
67+
isOutdated
68+
path
69+
line
70+
comments(first: 30) {
71+
nodes {
72+
author { login }
73+
body
74+
createdAt
75+
}
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}'
82+
```
83+
84+
### Thread classification
85+
86+
For each thread, classify it into one of three buckets:
87+
88+
| Bucket | Criteria | Action |
89+
|--------|----------|--------|
90+
| **Resolved** | `isResolved: true` | Analyze for insights |
91+
| **Effectively resolved** | `isResolved: false`, but has replies where the PR author acknowledged the feedback (e.g., "done", "fixed", "changed to X", "good point, updated", or any reply indicating the feedback was accepted and acted upon) | Analyze for insights |
92+
| **Unresolved / Rejected** | `isResolved: false`, and either no replies, or the PR author pushed back / debated without acting on it, or the thread is an open question with no conclusion | **Skip entirely** |
93+
94+
**Important:** Do NOT use keyword matching for the "effectively resolved" bucket. Read the full thread conversation and use semantic understanding to judge whether the PR author acknowledged and acted on the feedback. The signal could be anything — a one-word "done", a detailed explanation of what they changed, or even just agreement followed by a code change.
95+
96+
### Additional filtering
97+
98+
After thread classification, also discard threads where:
99+
- All comments are from bots (user login ends with `[bot]`)
100+
- The reviewer's comment is fewer than 10 characters (too short to contain insight)
101+
- The thread is purely automated (`/`, `<!--` prefixes)
102+
103+
Collect all remaining **resolved + effectively resolved** threads with their PR context (PR number, title, state).
104+
105+
---
106+
107+
## Step 4: Read Current Documentation
108+
109+
Read all five documentation files:
110+
111+
1. `CLAUDE.md`
112+
2. `Agents.md`
113+
3. `agent_docs/architecture.md`
114+
4. `agent_docs/conventions.md`
115+
5. `agent_docs/rules.md`
116+
117+
---
118+
119+
## Step 5: Analyze Threads for Insights
120+
121+
For each resolved/effectively-resolved thread, perform a two-stage analysis:
122+
123+
### Stage 1: Validity and resolution extraction
124+
125+
Read the **full thread conversation** and determine:
126+
127+
1. **Was the feedback valid?** — Did the reviewer raise a legitimate concern about a pattern, convention, architecture decision, or quality issue? Or was it a misunderstanding, a personal preference, or something the PR author correctly pushed back on?
128+
2. **What was the resolution?** — If valid, what specifically changed? Extract the concrete action taken (e.g., "switched from NetworkError to ErrorFactory", "moved folderId from positional param to options object", "added unit test for bound methods").
129+
3. **Is it generalizable?** — Is this a one-off fix for this specific PR, or does it reveal a pattern/rule that applies to future work?
130+
131+
Skip threads where the feedback was invalid, the resolution is unclear, or the lesson is not generalizable.
132+
133+
### Stage 2: Documentation mapping
134+
135+
For each thread that passes Stage 1, determine if it contains a documentation-worthy insight:
136+
137+
| Signal | Target file |
138+
|--------|-------------|
139+
| Reviewer correcting a pattern violation not yet in rules | `agent_docs/rules.md` |
140+
| Explaining WHY a convention exists or should be followed | `agent_docs/conventions.md` |
141+
| New project structure info, service patterns, or architecture decisions | `agent_docs/architecture.md` |
142+
| New commands, quick-reference items, or workflow changes | `Agents.md` |
143+
| Top-level pointers or high-level project changes (rare) | `CLAUDE.md` |
144+
145+
### Ignore (skip these)
146+
147+
- One-off bug fixes with no general lesson
148+
- Typo corrections or nit fixes
149+
- Insights already documented in the existing files
150+
- Subjective style preferences without team consensus
151+
- Threads where the resolution was just "removed" or "deleted" with no broader lesson
152+
153+
### Deduplication
154+
155+
If multiple threads across different PRs express the same insight, consolidate into a single documentation change and cite all source PRs.
156+
157+
---
158+
159+
## Step 6: Propose and Apply Changes
160+
161+
If no actionable insights are found, report:
162+
163+
```
164+
No documentation-worthy insights found in {X} PRs with {Y} comments from {START_DATE} to {END_DATE}.
165+
```
166+
167+
And stop. Do not create a PR.
168+
169+
If actionable insights exist:
170+
171+
1. For each insight, determine the correct file and section.
172+
2. Edit the files using the Edit tool. Follow existing formatting, heading levels, and conventions in each file.
173+
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.
174+
4. For `agent_docs/conventions.md`, add to the relevant section or create a new subsection following existing patterns.
175+
5. For `agent_docs/architecture.md`, update tables or sections as appropriate.
176+
6. For `Agents.md`, update the quick reference or add new sections.
177+
178+
---
179+
180+
## Step 7: Create or Update PR
181+
182+
### Check for existing PR
183+
184+
```bash
185+
gh pr list --repo UiPath/uipath-typescript --label "claude-docs-update" --state open --json number,headRefName
186+
```
187+
188+
### Ensure label exists
189+
190+
```bash
191+
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
192+
```
193+
194+
### Branch naming
195+
196+
```bash
197+
BRANCH_NAME="claude-docs-update/$(date +%Y-%m-%d)"
198+
```
199+
200+
### If existing open PR found
201+
202+
1. Check out the existing PR branch.
203+
2. Commit changes with message: `docs: update claude docs from PR review analysis (${START_DATE} to ${END_DATE})`
204+
3. Push to the existing branch.
205+
4. Update the PR body with the new analysis using `gh pr edit`.
206+
207+
### If no existing PR
208+
209+
1. Create and check out the new branch from `main`.
210+
2. Stage and commit all changed documentation files.
211+
- Commit message: `docs: update claude docs from PR review analysis (${START_DATE} to ${END_DATE})`
212+
3. Push the branch.
213+
4. Create the PR:
214+
215+
```bash
216+
gh pr create \
217+
--repo UiPath/uipath-typescript \
218+
--title "docs: update Claude docs from PR review analysis" \
219+
--label "claude-docs-update" \
220+
--reviewer "shreyash0502" \
221+
--body "$(cat <<'EOF'
222+
## Summary
223+
Weekly analysis of PR comments ({START_DATE} -> {END_DATE}).
224+
Analyzed {X} PRs with {Y} comments. Found {Z} actionable insights.
225+
226+
## Changes
227+
### {file_path}
228+
- **{Change description}**
229+
Source: PR #{N} -- @{reviewer} commented on `{file}:{line}`:
230+
> "{original comment}"
231+
232+
### No changes
233+
- {files not modified} -- no relevant insights found
234+
235+
## PRs Analyzed
236+
| PR | Title | State | Comments |
237+
|----|-------|-------|----------|
238+
| #{N} | {title} | {state} | {count} |
239+
EOF
240+
)"
241+
```
242+
243+
**PR body rules:**
244+
- Replace all `{placeholders}` with actual values.
245+
- The **Changes** section must list every file modified with the specific change, source PR, reviewer, and original comment quote.
246+
- The **No changes** section must list files that were read but had no relevant insights.
247+
- The **PRs Analyzed** table must list every PR that was fetched, regardless of whether it yielded insights.
248+
- State values: `merged`, `open`, `closed`.
249+
250+
---
251+
252+
## Output
253+
254+
After completion, report:
255+
256+
```
257+
## Claude Docs Enhancement Summary
258+
259+
**Date range:** {START_DATE} to {END_DATE}
260+
**PRs analyzed:** {X}
261+
**Comments reviewed:** {Y}
262+
**Actionable insights:** {Z}
263+
264+
### Changes made
265+
- {file}: {brief description of changes}
266+
267+
### PR
268+
{PR URL or "No PR created -- no actionable insights found"}
269+
```
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)