Skip to content

Commit cd8e871

Browse files
authored
Merge pull request #338 from netwrix/dev
doc review diff only
2 parents ca1c923 + a8d129a commit cd8e871

2 files changed

Lines changed: 36 additions & 99 deletions

File tree

.github/workflows/claude-documentation-fixer.yml

Lines changed: 25 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,14 @@ name: Documentation Fixer
33
on:
44
issue_comment:
55
types: [created]
6-
pull_request_review_comment:
7-
types: [created]
86

97
jobs:
108
claude-response:
119
runs-on: ubuntu-latest
1210
if: |
13-
(
14-
github.event_name == 'issue_comment' &&
15-
github.event.issue.pull_request &&
16-
contains(github.event.comment.body, '@claude') &&
17-
github.event.comment.user.login != 'github-actions[bot]'
18-
) || (
19-
github.event_name == 'pull_request_review_comment' &&
20-
contains(github.event.comment.body, '@claude') &&
21-
github.event.comment.user.login != 'github-actions[bot]'
22-
)
11+
github.event.issue.pull_request &&
12+
contains(github.event.comment.body, '@claude') &&
13+
github.event.comment.user.login != 'github-actions[bot]'
2314
permissions:
2415
contents: write
2516
pull-requests: write
@@ -32,11 +23,7 @@ jobs:
3223
env:
3324
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3425
run: |
35-
if [ "${{ github.event_name }}" = "issue_comment" ]; then
36-
PR_NUMBER="${{ github.event.issue.number }}"
37-
else
38-
PR_NUMBER="${{ github.event.pull_request.number }}"
39-
fi
26+
PR_NUMBER="${{ github.event.issue.number }}"
4027
PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName,isCrossRepository)
4128
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
4229
echo "branch=$(echo "$PR_DATA" | jq -r '.headRefName')" >> "$GITHUB_OUTPUT"
@@ -57,69 +44,37 @@ jobs:
5744
ref: ${{ steps.pr-info.outputs.branch }}
5845
fetch-depth: 0
5946

60-
- name: Build prompt for review comment reply
61-
id: build-prompt
62-
if: steps.pr-info.outputs.is_fork == 'false' && github.event_name == 'pull_request_review_comment'
63-
env:
64-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
COMMENT_BODY: ${{ github.event.comment.body }}
66-
FILE_PATH: ${{ github.event.comment.path }}
67-
LINE: ${{ github.event.comment.line }}
68-
IN_REPLY_TO: ${{ github.event.comment.in_reply_to_id }}
69-
run: |
70-
if [ -n "$IN_REPLY_TO" ] && [ "$IN_REPLY_TO" != "0" ]; then
71-
PARENT_BODY=$(gh api repos/${{ github.repository }}/pulls/comments/$IN_REPLY_TO --jq '.body')
72-
else
73-
PARENT_BODY="$COMMENT_BODY"
74-
fi
47+
- name: Checkout system prompt repository
48+
if: steps.pr-info.outputs.is_fork == 'false'
49+
uses: actions/checkout@v4
50+
with:
51+
repository: netwrix-eng/internal-agents
52+
token: ${{ secrets.PRIVATE_AGENTS_REPO }}
53+
path: system-prompt-repo
54+
ref: builds
55+
sparse-checkout: |
56+
engineering/technical_writing/system-prompt.md
57+
sparse-checkout-cone-mode: false
7558

59+
- name: Read system prompt
60+
id: read-prompt
61+
if: steps.pr-info.outputs.is_fork == 'false'
62+
run: |
7663
{
7764
echo "prompt<<EOF"
78-
echo "The user replied to an inline review comment on PR #${{ steps.pr-info.outputs.number }}."
79-
echo ""
80-
echo "User's reply: $COMMENT_BODY"
81-
echo ""
82-
echo "Parent inline comment:"
83-
echo "$PARENT_BODY"
84-
echo ""
85-
echo "File: \`$FILE_PATH\`, line: $LINE."
86-
echo ""
87-
echo "Based on the user's reply:"
88-
echo "- If they asked to apply the suggestion: extract the text from the 'Suggested change:' code block in the parent comment. Open \`$FILE_PATH\`, replace the content at line $LINE with that text, then stage, commit, and push the change."
89-
echo "- If they asked to add the suggestion to a batch: find or create a PR comment from github-actions[bot] that starts with '<!-- CLAUDE-BATCH-TRACKER -->'. Add this suggestion to the list and rewrite the comment using exactly this format (replacing N with the updated count and updating the list):"
90-
echo ""
91-
echo " <!-- CLAUDE-BATCH-TRACKER -->"
92-
echo " **Batched suggestions: N**"
93-
echo " Comment \`@claude apply batch\` on this PR to apply all of them."
94-
echo ""
95-
echo " | # | File | Line | Suggested change |"
96-
echo " |---|------|------|------------------|"
97-
echo " | 1 | \`path/to/file.md\` | 12 | suggested text |"
98-
echo " | 2 | \`path/to/file.md\` | 34 | suggested text |"
99-
echo ""
100-
echo " Then post a reply to the inline comment thread: 'Added to batch (N total). Comment \`@claude apply batch\` on this PR to apply all batched suggestions.'"
65+
cat system-prompt-repo/engineering/technical_writing/system-prompt.md
66+
echo "" # Forces a newline to prevent EOF delimiter errors
10167
echo "EOF"
10268
} >> "$GITHUB_OUTPUT"
10369
104-
- name: Apply fixes (PR comment)
105-
if: steps.pr-info.outputs.is_fork == 'false' && github.event_name == 'issue_comment'
106-
uses: anthropics/claude-code-action@v1
107-
with:
108-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
109-
github_token: ${{ secrets.GITHUB_TOKEN }}
110-
show_full_output: true
111-
claude_args: |
112-
--model claude-sonnet-4-5-20250929
113-
--allowedTools "Read,Write,Edit,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Bash(gh api:*),Bash(git config:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)"
114-
115-
- name: Apply fixes (review comment reply)
116-
if: steps.pr-info.outputs.is_fork == 'false' && github.event_name == 'pull_request_review_comment'
70+
- name: Apply fixes
71+
if: steps.pr-info.outputs.is_fork == 'false'
11772
uses: anthropics/claude-code-action@v1
11873
with:
11974
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
12075
github_token: ${{ secrets.GITHUB_TOKEN }}
12176
show_full_output: true
122-
prompt: ${{ steps.build-prompt.outputs.prompt }}
12377
claude_args: |
12478
--model claude-sonnet-4-5-20250929
125-
--allowedTools "Read,Write,Edit,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Bash(gh api:*),Bash(git config:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)"
79+
--allowedTools "Read,Write,Edit,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Bash(git config:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)"
80+
--append-system-prompt "${{ steps.read-prompt.outputs.prompt }}"

.github/workflows/claude-documentation-reviewer.yml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,16 @@ jobs:
8989
9090
Follow these steps in order:
9191
92-
1. Use the Read tool to read each file in full. Do not look at the PR diff yet.
92+
1. Use `gh pr diff ${{ github.event.pull_request.number }}` to get the lines that were added or modified in this PR.
9393
94-
2. Identify ALL issues in the document per your instructions.
94+
2. Review ONLY the added or modified lines from the diff for issues per your instructions. Do not report issues on lines that were not changed.
9595
96-
3. Use `gh pr diff ${{ github.event.pull_request.number }}` to get the list of lines that were added or modified in this PR.
97-
98-
4. Categorize each issue from step 2 as either:
99-
- Issues in PR changes: the issue is on a line that was added or modified in this PR
100-
- Preexisting issues: the issue exists on a line that was not changed by this PR
101-
102-
You MUST write your complete review to `/tmp/review-summary.md` — always, even if there are no issues. Use this exact structure — two sections, each containing a flat list of issues in the format from your instructions, with no subheadings, groupings, or extra nesting:
96+
3. You MUST write your complete review to `/tmp/review-summary.md` — always, even if there are no issues. Use this exact structure — a flat list of issues in the format from your instructions, with no subheadings, groupings, or extra nesting:
10397
10498
## Issues in PR changes
10599
<flat list of issues in the format from your instructions, or "None." if there are none>
106100
107-
## Preexisting issues
108-
<flat list of issues in the format from your instructions, or "None." if there are none>
109-
110-
Then fix ALL issues directly in the files using the Write and Edit tools. Do not post a PR comment. Do not commit or push.
101+
4. Fix ALL issues directly in the files using the Write and Edit tools. Do not post a PR comment. Do not commit or push.
111102
112103
claude_args: |
113104
--model claude-sonnet-4-5-20250929
@@ -132,24 +123,15 @@ jobs:
132123
133124
FOOTER = (
134125
"\n---\n\n"
135-
"To apply individual fixes, reply to the inline comments on this review"
136-
" with `@claude apply suggestion`.\n"
137-
"To batch fixes, reply with `@claude add suggestion to batch` on each inline comment,"
138-
" then comment `@claude apply batch` on this PR when ready.\n"
139-
"To fix issues in bulk, reply with `@claude` here, followed by your instructions"
140-
" (e.g. `@claude fix all issues` or `@claude fix only the spelling errors`"
141-
" or `@claude fix all other existing issues`"
142-
" or `@claude fix all linting issues`)."
143-
" You can use this option to fix preexisting issues.\n\n"
126+
"To apply suggested fixes to the updated documentation, individually or in bulk, comment `@claude`"
127+
" on this PR followed by your instructions (`@claude fix all issues`"
128+
" or `@claude fix all linting issues` or `@claude fix only the spelling errors`).\n\n"
129+
"To review and fix other preexisting issues in the updated documentation, comment `@claude` on this PR"
130+
" followed by your instructions (`@claude review preexisting issues`"
131+
" or `@claude fix preexisting issues`).\n\n"
144132
"Note: Automated fixes are only available for branches in this repository, not forks."
145133
)
146134
147-
INLINE_FOOTER = (
148-
"\n\n---\n\n"
149-
"Reply with `@claude`, followed by your instructions"
150-
" (e.g. `@claude apply suggestion` or `@claude add suggestion to batch`)."
151-
)
152-
153135
def parse_diff_to_suggestions(diff_text):
154136
suggestions = []
155137
current_file = None
@@ -226,7 +208,7 @@ jobs:
226208
return None # Pure insertions cannot be placed as inline comments
227209
end_line = old_start + len(old_chunk) - 1
228210
new_text = '\n'.join(new_chunk)
229-
comment_body = f"Suggested change:\n```\n{new_text}\n```{INLINE_FOOTER}"
211+
comment_body = f"```suggestion\n{new_text}\n```"
230212
comment = {
231213
'path': path,
232214
'line': end_line,

0 commit comments

Comments
 (0)