Add the grumpy-reviewer agent from github/gh-aw as an automatic PR-review agentic workflow (gh-aw) in this repo (ohcnetwork/care_fe). This repo already uses GitHub Agentic Workflows — see the existing .github/workflows/thank-you-note.md (+ .lock.yml) and .github/workflows/daily-playwright-improver.md (+ .lock.yml) for the exact conventions to follow (frontmatter style, permissions: read-all, tools.github.toolsets, safe-outputs, the if: ${{ github.repository == 'ohcnetwork/care_fe' }} upstream guard, and the compiled .lock.yml + .gitattributes pattern).
What to do
Install/verify the gh-aw CLI so you can compile:
gh aw version — if missing, install with curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh | bash; if present, gh extension upgrade aw.
Add the agent file at .github/agents/grumpy-reviewer.agent.md with EXACTLY the content from https://raw.githubusercontent.com/github/gh-aw/main/.github/agents/grumpy-reviewer.agent.md (fetch it fresh; do not paraphrase). It has frontmatter name: grumpy-reviewer, description, tools: [read, search], disable-model-invocation: true and a grumpy-code-reviewer prompt body.
Create the workflow.github/workflows/grumpy-reviewer.md that imports the agent and runs automatically on every pull request. Requirements:
Trigger automatically on PRs: opened, reopened, and synchronize (new commits).
It must also work for community/fork PRs. Because pull_request from forks does NOT expose repo secrets/the Copilot token, prefer pull_request_target (matching the existing thank-you-note.md, which uses pull_request_target) so external contributor PRs are reviewed too. Consult the gh-aw fork-support docs (https://raw.githubusercontent.com/github/gh-aw/main/docs/src/content/docs/reference/fork-support.md) to choose correctly and configure it safely.
Add workflow_dispatch: as well for manual runs.
Guard with if: ${{ github.repository == 'ohcnetwork/care_fe' }} like daily-playwright-improver.md.
safe-outputs: use create-pull-request-review-comment (max 10) so it leaves inline review comments on changed lines. Optionally also add submit-pull-request-review to post a consolidated review, and missing-tool: create-issue: true. Keep it focused on the PR's changed lines only.
Write a short prompt body instructing the agent to review only the changed lines of the triggering PR and leave grumpy-but-constructive inline review comments, deferring tone/behavior to the imported agent.
Treat all repo/PR content as untrusted input (security note like the other workflows).
Use the default engine (copilot) — the other workflows omit engine:, so do the same.
Compile: run gh aw compile (compile all, or the specific workflow) to generate .github/workflows/grumpy-reviewer.lock.yml. Fix any compile errors the tool reports. Ensure .gitattributes still contains .github/workflows/*.lock.yml linguist-generated=true merge=ours (it already does).
Do NOT run the app build/test suite — this is workflow config only. Validate solely via gh aw compile succeeding and git status showing the expected files.
Commit on a new branch and open a PR to ohcnetwork/care_fe (base develop). Stage only: .github/agents/grumpy-reviewer.agent.md, .github/workflows/grumpy-reviewer.md, .github/workflows/grumpy-reviewer.lock.yml, and .gitattributes if changed. PR title e.g. Add grumpy-reviewer agentic PR-review workflow. In the PR body, explain what it does and that it triggers automatically on every PR (opened/reopened/synchronize) plus manual dispatch, and note it needs copilot-requests: write / the Copilot engine credentials to be configured on the repo (mention this as a follow-up if not already set).
Report back the branch name, the PR URL, and a summary of the files added once done.
Assistant
I'll start by renaming the branch, then explore the existing gh-aw conventions in this repo.
Assistant
Let me examine the existing workflows and conventions.
Assistant
Now let me check the gh-aw CLI, fetch the agent content, and consult the fork-support docs.
Assistant
The CLI is ready (v0.80.9). Let me check the safe-outputs and triggers docs for the review-comment outputs and pull_request_target handling.
Assistant
Let me fetch the PR-specific safe-outputs page to get exact syntax for create-pull-request-review-comment and check for submit-pull-request-review.
Assistant
I have enough on safe-outputs. Let me quickly verify the imports mechanism and how pull_request_target compiles, then check the existing agent file for reference.
Assistant
The lock file uses GH_AW_REQUIRED_ROLES: admin,maintainer,write. That's a default role guard that would block fork contributors (who lack write access) — defeating the "review community PRs" goal. Let me check the roles/security docs to configure this correctly.
Assistant
I now have a clear picture. Key decision: pull_request_target enforces a default role gate of [admin, maintainer, write], which would skip fork contributors. To actually review community/fork PRs, I'll set roles: all — safe here because the agent runs read-only via the safe-outputs pattern (only separate safe-output jobs post comments). Let me create the agent file and workflow.
Assistant
Now the workflow file:
Assistant
Now let me compile with gh aw compile:
Assistant
Compiles with 0 errors, but there's an important security warning: pull_request_target + checkout is a "pwn request" vector. This workflow doesn't need a checkout at all — the agent reads the diff via the GitHub API. Let me disable checkout. Let me confirm the correct field placement.
Assistant
checkout: false is a top-level frontmatter key. Since the agent reads the PR via the GitHub API, no local checkout is needed — this eliminates the pwn-request risk. Let me add it and recompile.
Assistant
0 errors, 0 warnings. Let me verify the generated lock file's key sections and confirm git status shows the expected files.
Assistant
Let me verify the roles gate (should be relaxed to all), the safe-output jobs, checkout disabling, and the actions-lock.json change.
Assistant
All key sections look correct: triggers, if guard, no role gate (roles: all), and the three safe-outputs. The actions-lock.json gained a pinned action — a legit compile artifact to commit. Let me verify the checkout_pr_branch.cjs reference at line 475 isn't checking out untrusted PR code into the agent job.
Assistant
The remaining "Checkout PR branch" step is the minimal, purpose-built step that the review-comment safe-outputs need to anchor comments to changed lines — the compiler reports 0 warnings, confirming this is the supported safe pattern (read-only agent in a firewall sandbox, no PR build/execution). Note the compile also added a required pin to .github/aw/actions-lock.json (additive — pins the setup@v0.80.9 action my lock references).
Let me do a final review of the workflow file before committing.
Assistant
Everything looks correct. .gitattributes already contains the required pattern (unchanged). Let me stage the files and commit.
Assistant
Let me use a message file to avoid shell quoting issues.
Assistant
Committed. Now let me push and open the PR.
Assistant
Branch pushed. Now let me open the PR against develop.
Assistant
PR created. Let me report back to the requesting session with the details it asked for.
Assistant
All done. The grumpy-reviewer agentic PR-review workflow is added, compiled cleanly, committed, and a PR is open against develop.
Summary of what I did:
Fetched the grumpy-reviewer agent verbatim from github/gh-aw → .github/agents/grumpy-reviewer.agent.md.
Wrote .github/workflows/grumpy-reviewer.md following the repo's existing gh-aw conventions: pull_request_target (opened/reopened/synchronize) + workflow_dispatch, the ohcnetwork/care_fe guard, permissions: read-all, imports the agent, tools.github.toolsets: [default], and create-pull-request-review-comment / submit-pull-request-review safe-outputs.
Compiled with gh aw compile (v0.80.9) → 0 errors, 0 warnings.
Two deliberate safety decisions beyond the literal spec, both to make fork-PR review actually work and stay secure:
roles: all — pull_request_target enforces a default [admin, maintainer, write] role gate that would silently skip external contributors; all is required for community PRs to be reviewed.
checkout: false — the agent reads the diff via the GitHub API, so no untrusted fork code is checked out into a secrets-bearing job (removes the pwn-request warning the compiler flagged).
One additive pin landed in .github/aw/actions-lock.json (the setup action the new lock references); existing pins and .gitattributes were untouched. Flagged the Copilot-engine credential requirement as a follow-up in the PR body.
User
How can this be used without a PAT?
Assistant
Let me confirm the exact mechanism and how it interacts with permissions: read-all before answering.
Assistant
I have what I need. Let me verify the exact frontmatter change compiles cleanly (since read-all is a shorthand string that can't be mixed with a map entry, adding copilot-requests: write requires switching to an explicit permissions map). Let me test it.
Assistant
Clean compile (0/0) and the copilot-requests info tip is gone. Let me confirm how the lock now wires inference (token-based vs. PAT fallback).
Assistant
That's the confirmation: lines 850/1434 now set COPILOT_GITHUB_TOKEN: ${{ github.token }} — the Copilot engine uses the built-in Actions GITHUB_TOKEN, not a user-supplied PAT secret. Let me add a short explanatory comment in the frontmatter, recompile, and update the PR.
Assistant
Clean. Let me commit and push to update the PR.
Assistant
Pushed. Let me update the PR body's follow-up section to reflect the no-PAT configuration.
Assistant
Done. To use this without a PAT, the key is token-based Copilot inference.
How it works without a PAT
By default the Copilot engine looks for a COPILOT_GITHUB_TOKEN secret (a PAT). Declaring copilot-requests: write in the workflow's permissions switches it to run on the built-in Actions GITHUB_TOKEN instead — no PAT secret needed. I've applied this and pushed it to the PR:
Verified in the compiled lock: the engine now gets COPILOT_GITHUB_TOKEN: ${{ github.token }} (the Actions token) rather than a secrets.* PAT. Compile is clean (0 errors / 0 warnings), and the earlier "set copilot-requests: write" tip is gone.
One requirement: this uses centralized org billing, so it must be enabled at Org → Settings → Copilot → Policies → Copilot CLI → "Allow use of Copilot CLI billed to the organization." With that on, the workflow runs entirely on the built-in token.
Alternatives if org billing isn't available:
Supply a COPILOT_GITHUB_TOKEN PAT secret (individual/seat billing) — the original fallback.
Mint a short-lived token from a GitHub App (github-app: config) instead of a classic PAT — not a PAT, but more setup.
Note: I narrowed permissions: read-all to explicit read scopes because Actions doesn't allow mixing the read-all shorthand with a copilot-requests: write entry; the read-only agent + safe-outputs jobs (which get their own write scopes) are unaffected.
User
If with PAT, what are the permissions needed? fine grainer?
Assistant
Let me check the gh-aw auth docs for the exact PAT scopes required for COPILOT_GITHUB_TOKEN.
Assistant
The auth doc path changed. Let me find the correct docs location.
Assistant
Yes — it must be a fine-grained PAT, and it needs exactly one permission.
The COPILOT_GITHUB_TOKEN PAT
Setting
Value
Token type
Fine-grained (classic tokens and OAuth gho_ tokens are rejected at runtime)
Account permissions → Copilot Requests
Read
Repository permissions
None needed
Owner
A user account with an active Copilot license
That's the whole list. This PAT is used only for Copilot inference (calling the model), not for reading the PR or posting comments — so it needs no repo scopes at all. GitHub even has a pre-fill link that sets the name + this permission:
Add it as a repo Actions secret named COPILOT_GITHUB_TOKEN (gh aw secrets set COPILOT_GITHUB_TOKEN --value "<pat>").
Where the GitHub API access comes from
Reading the diff and posting review comments does not use this PAT — those run on the built-in Actions GITHUB_TOKEN. gh-aw auto-injects the write scopes into the separate safe-output jobs (pull-requests: write), while the agent job stays read-only. So the workflow's own permissions: block is unaffected.
To actually switch this workflow to PAT mode
The current file uses copilot-requests: write (no PAT). If you go the PAT route instead, just drop that line — since when it's present, COPILOT_GITHUB_TOKEN is ignored for inference:
Optional: if you ever want safe-outputs to authenticate with a PAT too (e.g. cross-repo), that's a separateGH_AW_GITHUB_TOKEN fine-grained PAT scoped to just Pull requests: write — not needed here.
Want me to flip the workflow to PAT mode, or keep the no-PAT copilot-requests: write config that's currently committed?
User
Revert to using PAT
Assistant
Reverting to PAT mode. Let me update the frontmatter to drop copilot-requests: write and restore permissions: read-all.
Assistant
Compiles clean (the info tip is just informational). Let me confirm the lock now uses the PAT secret for inference rather than github.token.
Assistant
Confirmed — inference now wires to secrets.COPILOT_GITHUB_TOKEN and copilot-requests is gone. Let me commit and push.
Assistant
Now let me update the PR body to reflect PAT mode.
Assistant
Done — reverted to PAT-based Copilot inference and pushed to the PR.
What changed:
Dropped copilot-requests: write and restored permissions: read-all.
The compiled lock now wires inference to secrets.COPILOT_GITHUB_TOKEN (verified at lines 196/853/1437), and copilot-requests is gone.
Compile: 0 errors / 0 warnings (the remaining message is just the informational "you could use copilot-requests" tip).
Updated the PR body's auth + follow-up sections.
To make it run, set this repo secret on ohcnetwork/care_fe:
COPILOT_GITHUB_TOKEN — a fine-grained PAT with Account permissions → Copilot Requests: Read (no repo scopes), owned by a Copilot-licensed account.
bash
gh aw secrets set COPILOT_GITHUB_TOKEN --value "<your-fine-grained-pat>"
Reading the PR and posting review comments still run on the built-in Actions GITHUB_TOKEN (safe-output jobs get pull-requests: write injected), so the PAT only needs the Copilot Requests scope.
User
Would this now run for all PRs? What triggers it?
Assistant
Let me check the current frontmatter and how the compiled lock gates activation.
Assistant
Yes — once merged, it runs on essentially every PR to ohcnetwork/care_fe. Here's the exact trigger picture from the current file:
What triggers it
pull_request_target with three activity types:
Type
Fires when
opened
a PR is created
reopened
a closed PR is reopened
synchronize
new commits are pushed to an open PR
Plus workflow_dispatch — manual runs from the Actions tab.
Which PRs are in scope
There are no narrowing filters in the frontmatter, so it's broad:
No branches: → any base branch (not just develop).
No paths: → any files changed.
No draft filter → draft PRs included too.
roles: all → any author, including first-time and fork/community contributors (that's the point of pull_request_target here).
What gates / limits it
if: github.repository == 'ohcnetwork/care_fe' — only runs on the upstream repo; skips cleanly on forks.
COPILOT_GITHUB_TOKEN must be set — otherwise the inference step fails.
Concurrency: one run per PR — a new push cancels/supersedes the in-flight run for that same PR.
Cost note: because it's unfiltered, every push to every open PR spends Copilot credits. If that's too much, you can scope it later (e.g. add branches: [develop], exclude drafts, or roles: [admin, maintainer, write] to skip fork PRs).
One important caveat
For pull_request_target, GitHub runs the workflow version from the base branch, not the PR branch. So it won't review this PR (#16616) itself — it only starts reviewing PRs after the workflow is merged to develop/default.
Want me to add any of those scoping filters (e.g. limit to develop, skip drafts), or leave it running on all PRs?
User
Was the yml generated from the md file? What is the source for this?
Assistant
Yes. Let me show you the proof from the generated file's own header.
Assistant
Yes — the .lock.yml is generated from the .md file. It says so in its own header (lines 3, 20–21):
# This file was automatically generated by gh-aw (v0.80.9). DO NOT EDIT.# To update this file, edit the corresponding .md file and run: gh aw compile
The source model
code
.github/workflows/grumpy-reviewer.md ← SOURCE (you edit this)
│
├── imports: .github/agents/grumpy-reviewer.agent.md ← merged in
│
▼ gh aw compile
.github/workflows/grumpy-reviewer.lock.yml ← GENERATED (do not edit)
grumpy-reviewer.md — the human-authored source: YAML frontmatter (triggers, permissions, tools, safe-outputs) + a Markdown prompt body. This is what I edited each time.
grumpy-reviewer.agent.md — the imported persona, folded in at compile time (listed under "Imports" at line 30).
grumpy-reviewer.lock.yml — the compiled artifact: a full, self-contained GitHub Actions workflow (~2,000 lines) that GitHub Actions actually runs. gh-aw expands the compact frontmatter into all the real jobs (activation/role checks, the sandboxed agent, safe-output jobs, firewall, etc.) and pins every action to a SHA.
How they stay in sync
Line 1 stores a frontmatter_hash and body_hash of the source. gh aw compile recompiles whenever the .md changes — that's why every edit I made (checkout: false, copilot-requests, the PAT revert) produced a matching .lock.yml change. This is also why .gitattributes marks *.lock.yml as linguist-generated — GitHub treats it as build output, not hand-written code.
Practically: edit only the .md; never hand-edit the .lock.yml. Run gh aw compile and commit both together (which is exactly what's in the PR).
User
Assistant
The logs make the problem clear: my checkout: false was wrong. The injected "Checkout PR branch" step runs git fetch origin +refs/pull/N/head — but with no base checkout there's no .git, so it dies with "not a git repository". And the imported agent uses tools: [read, search], which read local files, so it genuinely needs the PR code checked out.
Let me research the correct safe-checkout pattern for a PR reviewer before fixing.
Assistant
There's a canonical reviewer example in the gh-aw repo. Let me fetch it to see how they handle checkout + pull_request_target.
Assistant
The canonical reviewer imports a shared pr-review-base.md. Let me check how it handles checkout and integrity gating.
User
hi
Assistant
Hi! I'm mid-investigation on the workflow failure you shared. Quick status:
Diagnosis: The agent job fails at "Checkout PR branch" with fatal: not a git repository. Root cause is my checkout: false — that skipped the base checkout, so there's no .git, and gh-aw's injected step (git fetch origin +refs/pull/N/head) has nothing to fetch into. The imported agent uses tools: [read, search], which read local files, so it genuinely needs the PR code on disk — checkout: false was the wrong call.
Fix: Remove checkout: false so the standard pull_request_target checkout runs (base repo checked out, then the PR head fetched into it), which is the supported reviewer pattern.
Want me to go ahead and apply that fix + recompile + push to the PR?
User
How do we test it?
Assistant
Good question — testing gh-aw workflows has some gotchas (especially the pull_request_target base-branch rule). Let me check what the CLI offers for this.
Assistant
Two commands matter here: gh aw run (dispatches on Actions) and gh aw trial (simulated repo). Let me get their specifics.
Assistant
Here are the realistic ways to test this, lightest → most end-to-end. Note one hard constraint up front: for pull_request_target, GitHub runs the workflow copy from the base branch, not from the PR — so it can't be validated from PR #16616 itself; the .lock.yml has to exist on the branch the run reads.
1. Static validation (no secret, no execution) — already passing
bash
gh aw compile grumpy-reviewer # 0 errors/0 warnings
gh aw lint # actionlint on the generated yml
gh aw run grumpy-reviewer --dry-run # validate dispatch wiring
2. gh aw trial — safest real run (recommended)
Spins up a temporary private repo in your account, runs the agent in trial mode, and captures the review comments without posting to ohcnetwork/care_fe. Can clone real repo state and simulate a PR:
Needs COPILOT_GITHUB_TOKEN available to that trial repo (or copilot billing).
3. gh aw run — dispatch the real workflow on a branch
Uses the workflow_dispatch trigger we added. --push commits/pushes the workflow first:
bash
gh aw run grumpy-reviewer --push --ref amjithtitus09-grumpy-reviewer-workflow
Caveat: on a bare dispatch there's no triggering PR, so you'd pass PR context via -F aw_context=.... Requires the secret set on the repo.
4. Full end-to-end pull_request_target
The screenshots (#16579, #14906) show you already got this to fire — that only works once the .lock.yml is on the base branch. So the true end-to-end is: merge to develop (or a test base), then open a throwaway PR and watch it review.
But first: every path above will hit the same Checkout PR branch failure until I apply the checkout: false fix. Want me to apply the fix, recompile, push, and then kick off a gh aw trial run so we can see it actually review a real PR safely?
User
We need to test before the PR is merged. Can this be tested in a different Repo or something?
Assistant
Yes — that's exactly what gh aw trial is for, and a personal fork is the other option. Let me confirm how trials handle the Copilot credential (since a personal repo has no org billing) so I give you the right steps.
Assistant
Yes — you can test it in a throwaway repo without merging. Let me apply the prerequisite checkout fix first (every test path fails without it), then I'll lay out the repo options.
Assistant
The comment and checkout: false are both wrong — the imported agent's read/search tools read local files, and gh-aw injects a "Checkout PR branch" step for PR events. Removing the base checkout is what broke it. Let me remove it so the standard checkout runs.
Assistant
Base checkout now runs before the PR fetch. Let me verify the ordering and what the base checkout pins to (it should be the trusted base ref under pull_request_target).
Assistant
Correct flow now: base checkout (line 446, persist-credentials: false = safe base ref under pull_request_target) → then PR head fetched into it. The pwn warning is inherent to any PR reviewer that reads PR files locally, and it's mitigated by the read-only sandboxed agent + safe-outputs. Let me commit and push the fix.
Assistant
Let me verify the push landed on the PR branch.
Assistant
Fix is pushed (local + origin at f7537d5). Now, on testing in a separate repo — yes, two ways, neither needs merging to develop:
Option A — gh aw trial (temp private repo, safest)
Creates a throwaway private repo in your account, runs the agent, and captures the review comments instead of posting them to care_fe. Use --logical-repo so the if: github.repository == 'ohcnetwork/care_fe' guard still passes:
Option B — your fork as a real base (true end-to-end, posts real comments)
Push the workflow to amjithtitus09/care_fe, open a throwaway PR against your fork's default branch, and watch it review for real. Two edits needed on the fork only (don't commit to this PR):
change the guard to if: ${{ github.repository == 'amjithtitus09/care_fe' }}
(fork PRs from others still won't get the token, but PRs you open within your fork will)
The one prerequisite either way
Whichever repo runs it needs the Copilot credential. Since personal repos have no org billing, set the PAT secret there — this is the one step only you can do (I won't handle the token value):
bash
gh secret set COPILOT_GITHUB_TOKEN --repo <that-repo> --body "<your-fine-grained-PAT>"
I can run Option A for you right now (it'll create amjithtitus09/gh-aw-trial and spend some Copilot credits). Want me to kick it off? If so, do you want to set the COPILOT_GITHUB_TOKEN on the trial repo first, or should I run it once so the repo gets created, then you add the secret and I re-run against it with --host-repo?