Skip to content

Commit 48700d7

Browse files
authored
Merge pull request #570 from netwrix/dev
vale-autofix-rework
2 parents c02e4f0 + d52676f commit 48700d7

13 files changed

Lines changed: 1731 additions & 376 deletions

File tree

.claude/skills/doc-pr-fix/SKILL.md

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: doc-pr-fix
3-
description: "Autonomous fixer for documentation PRs. Triggered by @claude comments on PRs targeting dev. Reads the writer's request, the doc-pr review comment, and the Vale linting comment, then applies fixes and commits. Use this skill whenever a writer tags @claude on a documentation PR — not for interactive help (use doc-help for that), but for autonomous, single-shot fixes in CI."
3+
description: "Autonomous fixer for documentation PRs. Triggered by @claude comments on PRs targeting dev. Reads the writer's request and the doc-pr review comment, then applies fixes and commits. Use this skill whenever a writer tags @claude on a documentation PR — not for interactive help (use doc-help for that), but for autonomous, single-shot fixes in CI."
44
argument-hint: "[pr-number] [writer-comment]"
55
---
66

@@ -20,8 +20,7 @@ You receive:
2020

2121
Parse the writer's comment to determine what they want. Common patterns:
2222

23-
- **Fix all issues** — apply every fix from the doc-pr review comment and the Vale linting comment
24-
- **Fix only Vale issues** — apply only fixes from the Vale linting comment
23+
- **Fix all issues** — apply every fix from the doc-pr review comment (Dale + editorial)
2524
- **Fix only Dale issues** — apply only Dale linting fixes
2625
- **Fix a specific issue** — apply one targeted fix
2726
- **Improve flow/clarity/structure** — editorial rewrite of specific content
@@ -37,34 +36,27 @@ Parse the writer's comment to determine what they want. Common patterns:
3736
gh api repos/{owner}/{repo}/issues/$PR_NUMBER/comments --jq '.[] | select(.body | contains("Documentation PR Review")) | .body' | tail -1
3837
```
3938
This tells you what Dale and the editorial review flagged.
40-
4. If the writer asks to fix Vale issues (or "all issues"), also find the Vale linting comment:
41-
```bash
42-
gh api repos/{owner}/{repo}/issues/$PR_NUMBER/comments --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("## Vale Linting"))) | .body' | tail -1
43-
```
44-
This gives you the Vale results table with file paths, line numbers, and rule violations.
4539

4640
## Step 3: Plan your work and post a progress comment
4741

4842
Use Todo to create a task for each discrete piece of work you need to do. Build the task list from what you learned in Steps 1–2. Each task should be concrete and trackable. Mark each task as complete as you finish it.
4943

5044
Example tasks for a "fix all issues" request:
51-
- Fix Vale issues in `path/to/file.md` (N issues)
52-
- Fix Vale issues in `path/to/other.md` (N issues)
5345
- Fix Dale issues in `path/to/file.md` (N issues)
5446
- Apply editorial suggestions
5547
- Verify changes
5648
- Commit and push
5749

58-
Only include tasks for what the writer actually asked for. If they said "fix only the Dale issues," your task list should contain Dale fixes, verify, and commit — no Vale tasks, no editorial tasks. The task list must reflect the writer's request exactly.
50+
Only include tasks for what the writer actually asked for. If they said "fix only the Dale issues," your task list should contain Dale fixes, verify, and commit — no editorial tasks. The task list must reflect the writer's request exactly.
5951

6052
Then post a PR comment mirroring your task list so the writer can see what you're doing:
6153

6254
```bash
6355
PROGRESS_COMMENT_ID=$(gh pr comment "$PR_NUMBER" --body "$(cat <<'EOF'
6456
**Fix in progress:**
6557
66-
- [ ] Fix Vale issues in `path/to/file.md` (N issues)
67-
- [ ] Fix Vale issues in `path/to/other.md` (N issues)
58+
- [ ] Fix Dale issues in `path/to/file.md` (N issues)
59+
- [ ] Apply editorial suggestions
6860
- [ ] Verify changes
6961
- [ ] Commit and push
7062
EOF
@@ -84,7 +76,6 @@ Update the PR comment at natural milestones (after finishing each file, after co
8476

8577
Work through the requested fixes methodically:
8678

87-
- For **Vale fixes**: read `docs/CLAUDE.md` for Vale guidance (especially the two rules requiring extra care), then fix each flagged issue in order, file by file
8879
- For **Dale fixes**: fix each flagged issue in order, file by file
8980
- For **editorial fixes from the review**: apply the suggested changes from the review comment
9081
- For **broader editorial requests** ("improve the flow", "make this clearer", "help with structure"): invoke `/doc-help` with the file path and the writer's request. Doc-help will analyze the document using its structured editing framework (structure, clarity, voice, surface). Since this is running in CI without an interactive writer, apply all of doc-help's suggestions autonomously rather than waiting for feedback
@@ -93,20 +84,7 @@ Work through the requested fixes methodically:
9384
When editing:
9485
- Use the Edit tool for targeted changes, Write for larger rewrites
9586
- Preserve the author's meaning and intent — fix the style, don't rewrite the content
96-
- Only change what was requested; don't fix other categories of issues even if they're on the same line (e.g., if asked to fix Vale issues, don't also fix Dale or editorial issues)
97-
98-
## Step 4b: Update the Vale Idioms rule
99-
100-
After applying fixes, check whether any Dale `idioms` violations or editorial items tagged `[idiom]` contained phrases not already in `.vale/styles/Netwrix/Idioms.yml`. For each new idiom:
101-
102-
1. Read `.vale/styles/Netwrix/Idioms.yml` to confirm the phrase isn't already covered (check for both exact matches and regex patterns that would match it).
103-
2. Add a new token entry under the most appropriate category comment. Follow existing conventions:
104-
- Use `\b` word boundaries for multi-word phrases.
105-
- Add optional inflection suffixes where the idiom can be conjugated (e.g., `\bgets? the ball rolling\b`).
106-
- Use single quotes around each token.
107-
3. Include the Idioms.yml file in your commit so the Vale rule grows over time.
108-
109-
If no new idioms were found, skip this step.
87+
- Only change what was requested; don't fix other categories of issues even if they're on the same line (e.g., if asked to fix Dale issues, don't also fix editorial issues)
11088

11189
## Step 5: Verify
11290

@@ -135,8 +113,8 @@ gh api repos/{owner}/{repo}/issues/comments/$PROGRESS_COMMENT_ID \
135113
-X PATCH -f body="$(cat <<'EOF'
136114
**Fix complete:**
137115
138-
- [x] Fix Vale issues in `path/to/file.md` (N issues)
139-
- [x] Fix Vale issues in `path/to/other.md` (N issues)
116+
- [x] Fix Dale issues in `path/to/file.md` (N issues)
117+
- [x] Apply editorial suggestions
140118
- [x] Verify changes
141119
- [x] Commit and push
142120
@@ -152,7 +130,7 @@ Skip progress tracking only for pure explanations (e.g., "why is this flagged?")
152130
## Behavioral Notes
153131

154132
- **Fix what's clear, ask about what isn't.** If a request has both obvious parts and ambiguous parts, apply the obvious fixes, commit and push those, then post a comment that summarizes what you did AND asks clarifying questions about the rest. The writer can reply with another `@claude` comment to continue.
155-
- **Never fix issues the writer didn't ask about.** If they said "fix the Vale issues," only fix Vale issues — don't also fix Dale issues, editorial issues, or rewrite sentences for clarity, even if the fix is on the same line.
133+
- **Never fix issues the writer didn't ask about.** If they said "fix the Dale issues," only fix Dale issues — don't also fix editorial issues or rewrite sentences for clarity, even if the fix is on the same line.
156134
- **If a fix would substantially change the author's meaning**, skip it and explain why in your summary comment. Ask the writer how they'd like to handle it.
157135
- **If the entire request is unclear**, don't edit anything — post a comment asking for clarification. It's better to ask one good question than to guess wrong and push unwanted changes.
158136
- **Each `@claude` comment is a fresh invocation.** You won't remember previous runs, so always re-read the PR diff and review comment for context.

.claude/skills/doc-pr/SKILL.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
name: doc-pr
3-
description: "Orchestrate a documentation review for pull requests targeting dev. Runs Dale linting and editorial review on changed markdown files, then posts a structured comment to the PR. Vale linting runs separately via the vale-linter workflow (inline review comments + summary PR comment). Use this skill whenever a PR involves markdown files in docs/ and targets the dev branch — triggered automatically by the doc-pr GitHub Actions workflow on PR open, sync, or when invoked manually via /doc-pr."
3+
description: "Orchestrate a documentation review for pull requests targeting dev. Runs Dale linting and editorial review on changed markdown files, then posts a structured comment to the PR. Vale issues are auto-fixed separately by the vale-autofix workflow. Use this skill whenever a PR involves markdown files in docs/ and targets the dev branch — triggered automatically by the doc-pr GitHub Actions workflow on PR open, sync, or when invoked manually via /doc-pr."
44
argument-hint: "[changed-files-csv] [pr-number]"
55
---
66

77
# Doc PR Review
88

99
You orchestrate a two-stage documentation review pipeline for pull requests. Your job is to run each stage, collect the results, and post a single comprehensive review comment to the PR.
1010

11-
Vale linting runs separately (via the vale-linter workflow) and posts inline review comments plus a summary PR comment. Do not run Vale or include Vale results in your review.
11+
Vale issues are auto-fixed separately by the vale-autofix workflow. Do not run Vale or include Vale results in your review.
1212

1313
Read `docs/CLAUDE.md` before starting — it contains the writing standards and Vale guidance you need for the editorial review stage.
1414

@@ -99,16 +99,15 @@ Write the full review body to `/tmp/doc-pr-review.md` using the Write tool. Foll
9999

100100
### Summary
101101

102-
N Dale issues, N editorial suggestions across N files. Vale issues are posted in a separate comment by the vale-linter workflow.
102+
N Dale issues, N editorial suggestions across N files. Vale issues are auto-fixed separately.
103103

104104
---
105105

106106
**What to do next:**
107107

108108
Comment `@claude` on this PR followed by your instructions to get help:
109109

110-
- `@claude fix all issues` — fix all Vale, Dale, and editorial issues
111-
- `@claude fix only the Vale issues` — fix just the Vale issues
110+
- `@claude fix all issues` — fix all Dale and editorial issues
112111
- `@claude help improve the flow of this document` — get writing assistance
113112
- `@claude explain the voice issues` — understand why something was flagged
114113

.github/workflows/claude-doc-pr.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ jobs:
168168
- Dale issues: ${{ steps.dale-post.outputs.dale_count }} (already posted as inline comments)
169169
- PR diff is at: /tmp/pr-diff.txt
170170
171-
NOTE: Vale linting runs separately (vale-linter workflow) and posts inline review comments plus a summary PR comment. Do not run Vale or include Vale issues in this review.
171+
NOTE: Vale issues are auto-fixed separately by the vale-autofix workflow. Do not run Vale or include Vale issues in this review.
172172
173173
INSTRUCTIONS:
174174
@@ -289,7 +289,7 @@ jobs:
289289
OWNER="${REPO%%/*}"
290290
NAME="${REPO##*/}"
291291
292-
# Resolve all Dale and Vale inline comment threads
292+
# Resolve all Dale inline comment threads
293293
THREAD_IDS=$(gh api graphql -f query='
294294
query($owner:String!,$name:String!,$pr:Int!) {
295295
repository(owner:$owner,name:$name) {
@@ -300,17 +300,17 @@ jobs:
300300
}
301301
}
302302
}' -f owner="$OWNER" -f name="$NAME" -F pr="$PR_NUMBER" \
303-
--jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false and ((.comments.nodes[0].body | contains("**Dale**")) or (.comments.nodes[0].body | contains("**Vale**")))) | .id' 2>/dev/null || true)
303+
--jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false and (.comments.nodes[0].body | contains("**Dale**"))) | .id' 2>/dev/null || true)
304304
for TID in $THREAD_IDS; do
305305
gh api graphql -f query='
306306
mutation($tid:ID!) {
307307
resolveReviewThread(input:{threadId:$tid}) { thread { isResolved } }
308308
}' -f tid="$TID" 2>/dev/null || true
309309
done
310310
311-
# Dismiss all previous Dale and Vale reviews
311+
# Dismiss all previous Dale reviews
312312
REVIEW_IDS=$(gh api repos/${REPO}/pulls/${PR_NUMBER}/reviews \
313-
--jq '[.[] | select(.user.login == "github-actions[bot]" and ((.body | contains("Dale found")) or (.body | contains("Vale found")))) | .id] | .[]' 2>/dev/null || true)
313+
--jq '[.[] | select(.user.login == "github-actions[bot]" and (.body | contains("Dale found"))) | .id] | .[]' 2>/dev/null || true)
314314
for ID in $REVIEW_IDS; do
315315
gh api repos/${REPO}/pulls/${PR_NUMBER}/reviews/${ID}/dismissals \
316316
-f message="Superseded after fixes applied" -f event="DISMISS" 2>/dev/null || true

0 commit comments

Comments
 (0)