You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gather context: checked existing workflows and project conventions
Create the missing workflow file — content ready (see below)
Attempt commit & push — blocked by GitHub App permissions
Blocked: workflows Permission Required
The GitHub App token used by this action lacks the workflows permission, which GitHub requires to push new .github/workflows/ files. This is a known limitation — see FAQ.
You'll need to manually create this file. The full content is below — it follows the same pinned-SHA, minimal-permissions conventions as the rest of the repo's workflows.
I couldn't access the petry-projects/.github standards doc directly (external network access was restricted in this run), so this implementation is based on the project context, the name "agent-shield", and common AI-agent security patterns. If the org standard defines a different implementation, adjust accordingly.
File to create: .github/workflows/agent-shield.yml
# Agent Shield## Security guardrails for AI agent activity in pull requests.# Detects PRs authored by AI agents (claude[bot], github-actions[bot], etc.)# and enforces the following protections:## 1. AI agents must not modify GitHub Actions workflow files — changes to# .github/workflows/** require an explicit human-authored commit on top.# 2. AI agents must not modify CI/CD configuration files without a human# co-author present in the commit history for that PR.# 3. Adds the "agent-pr" label to AI-authored PRs for triage visibility.## Add "Agent Shield" as a required status check in branch protection so that# human reviewers always see the result before merging.name: Agent Shieldon:
pull_request:
branches: [main]types: [opened, synchronize, reopened]permissions: {}jobs:
shield:
name: Agent Shieldruns-on: ubuntu-latestpermissions:
contents: readpull-requests: writesteps:
- name: Checkout repositoryuses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4with:
fetch-depth: 0
- name: Detect AI agent authorid: detectenv:
ACTOR: ${{ github.event.pull_request.user.login }}run: | # Known AI agent patterns (login ends in [bot] or matches known AI agents) if [[ "$ACTOR" == *"[bot]" ]]; then echo "is_agent=true" >> "$GITHUB_OUTPUT" echo "actor=$ACTOR" >> "$GITHUB_OUTPUT" echo "::notice::PR authored by AI agent: $ACTOR" else echo "is_agent=false" >> "$GITHUB_OUTPUT" echo "actor=$ACTOR" >> "$GITHUB_OUTPUT" fi
- name: Block unauthorized workflow modificationsif: steps.detect.outputs.is_agent == 'true'env:
BASE_REF: ${{ github.event.pull_request.base.ref }}run: | # Fail if any commit in the PR touches .github/workflows/ changed=$(git diff --name-only "origin/${BASE_REF}...HEAD" -- '.github/workflows/' || true) if [ -n "$changed" ]; then echo "::error::AI agent PRs must not modify GitHub Actions workflow files." echo "::error::Files changed: $changed" echo "::error::A human must author any workflow changes." exit 1 fi
- name: Check for human co-author on sensitive pathsif: steps.detect.outputs.is_agent == 'true'env:
BASE_REF: ${{ github.event.pull_request.base.ref }}run: | # Sensitive paths that require a human co-author in commit trailers sensitive_patterns=( '.github/' 'infra/' 'Dockerfile' '*.env*' ) sensitive_changed="" for pattern in "${sensitive_patterns[@]}"; do matches=$(git diff --name-only "origin/${BASE_REF}...HEAD" -- "$pattern" 2>/dev/null || true) if [ -n "$matches" ]; then sensitive_changed="$sensitive_changed $matches" fi done if [ -n "$sensitive_changed" ]; then # Check that at least one commit has a human Co-authored-by trailer has_human=false while IFS= read -r sha; do trailers=$(git log -1 --format='%(trailers:key=Co-authored-by,valueonly)' "$sha") if echo "$trailers" | grep -qiv '\[bot\]'; then has_human=true break fi done < <(git log --format='%H' "origin/${BASE_REF}...HEAD") if [ "$has_human" = "false" ]; then echo "::error::Sensitive paths changed by AI agent without a human co-author." echo "::error::Paths:$sensitive_changed" echo "::error::Add a human Co-authored-by trailer to at least one commit." exit 1 fi fi
- name: Label AI agent PRif: steps.detect.outputs.is_agent == 'true'env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}PR_NUMBER: ${{ github.event.pull_request.number }}run: | gh pr edit "$PR_NUMBER" --add-label "agent-pr" 2>/dev/null || true
Steps to apply
Create .github/workflows/agent-shield.yml with the content above (or push from the branch claude/issue-74-20260406-0221 — the commit is already staged locally)
Create the agent-pr label in repository settings (or it will be silently skipped)
Optionally add "Agent Shield" as a required status check in branch protection
If the petry-projects org standard defines a specific reusable workflow call instead, please share it and I can update the implementation.
Push attempt — blocked by GitHub App workflows permission
Blocked: workflows Permission Required
The GitHub App token lacks the workflows permission that GitHub requires to push new .github/workflows/ files. This is a known limitation — see FAQ.
You'll need to manually create this file. Based on the claude.yml thin-caller pattern used in this repo, here is the content:
File to create: .github/workflows/agent-shield.yml
# Agent Shield — thin caller that delegates to the org-level reusable workflow.# All logic is maintained centrally in agent-shield-reusable.yml.# Standard: https://github.com/petry-projects/.github/blob/main/standards/ci-standards.md#required-workflowsname: Agent Shieldon:
pull_request:
branches: [main]types: [opened, synchronize, reopened]permissions: {}jobs:
agent-shield:
uses: petry-projects/.github/.github/workflows/agent-shield-reusable.yml@mainsecrets: inheritpermissions:
contents: readpull-requests: write
Rationale
All other org-managed workflows in this repo (e.g. claude.yml) follow a thin-caller pattern: the file in this repo just calls a reusable workflow maintained centrally in petry-projects/.github. I followed the same convention here, calling agent-shield-reusable.yml@main from the org's .github repo.
If the org standard requires a different implementation (e.g. standalone logic instead of a reusable call, or different triggers/permissions), please refer to the ci-standards.md#required-workflows doc and adjust accordingly.
Steps to apply
Create .github/workflows/agent-shield.yml with the content above (needs a user or token with the workflows scope)
Push to main or open a PR — the compliance audit should then pass
CI green (see note below) — tagged @don-petry to review and merge
Self-Review
The file follows the thin-caller convention exactly — identical structure to claude.yml and feature-ideation.yml:
Check
Result
Pattern consistency with claude.yml / feature-ideation.yml
✓
permissions: {} at workflow level (least privilege)
✓
Job-level permissions scoped to contents: read + pull-requests: write
✓
Correct triggers: pull_request on main, all three standard types
✓
Reusable workflow reference @main (consistent with other callers)
✓
secrets: inherit present for reusable workflow
✓
CI Results
Check
Result
CI / Go
✅
CI / TypeScript
✅
CodeQL
✅
Dependency audit
✅
SonarCloud (GitHub Actions)
✅
CodeRabbit
✅
SonarCloud Code Analysis (sonarcloud.io status context)
⚠️ FAILURE — pre-existing, unrelated to this YAML-only change
The direct SonarCloud status context failure is pre-existing — this PR adds only a YAML workflow file with no source code, so it cannot affect code quality metrics.
| View PR
The agent-shield.yml file was copied verbatim from the org standard template at petry-projects/.github/standards/workflows/agent-shield.yml. It's a thin-caller stub delegating to agent-shield-reusable.yml@v1 with contents: read permissions.
Activity
claude commentedon Apr 6, 2026
Claude finished @don-petry's task in 5m 27s —— View job
Compliance Fix:
agent-shield.ymlRequiredBlocked:
workflowsPermission RequiredThe GitHub App token used by this action lacks the
workflowspermission, which GitHub requires to push new.github/workflows/files. This is a known limitation — see FAQ.You'll need to manually create this file. The full content is below — it follows the same pinned-SHA, minimal-permissions conventions as the rest of the repo's workflows.
File to create:
.github/workflows/agent-shield.ymlSteps to apply
.github/workflows/agent-shield.ymlwith the content above (or push from the branchclaude/issue-74-20260406-0221— the commit is already staged locally)agent-prlabel in repository settings (or it will be silently skipped)If the petry-projects org standard defines a specific reusable workflow call instead, please share it and I can update the implementation.
don-petry commentedon Apr 6, 2026
Weekly Compliance Audit (2026-04-06)
This finding is still open.
Detail: Required workflow
agent-shield.ymlis missingStandard: standards/ci-standards.md#required-workflows
don-petry commentedon Apr 6, 2026
Weekly Compliance Audit (2026-04-06)
This finding is still open.
Detail: Required workflow
agent-shield.ymlis missingStandard: standards/ci-standards.md#required-workflows
don-petry commentedon Apr 6, 2026
Weekly Compliance Audit (2026-04-06)
This finding is still open.
Detail: Required workflow
agent-shield.ymlis missingStandard: standards/ci-standards.md#required-workflows
don-petry commentedon Apr 6, 2026
Weekly Compliance Audit (2026-04-06)
This finding is still open.
Detail: Required workflow
agent-shield.ymlis missingStandard: standards/ci-standards.md#required-workflows
don-petry commentedon Apr 6, 2026
Claude finished @don-petry's task in 2m 21s —— View job
Compliance Fix:
agent-shield.ymlRequired.github/workflows/agent-shield.yml(followingclaude.ymlthin-caller pattern)workflowspermissionBlocked:
workflowsPermission RequiredThe GitHub App token lacks the
workflowspermission that GitHub requires to push new.github/workflows/files. This is a known limitation — see FAQ.You'll need to manually create this file. Based on the
claude.ymlthin-caller pattern used in this repo, here is the content:File to create:
.github/workflows/agent-shield.ymlRationale
All other org-managed workflows in this repo (e.g.
claude.yml) follow a thin-caller pattern: the file in this repo just calls a reusable workflow maintained centrally inpetry-projects/.github. I followed the same convention here, callingagent-shield-reusable.yml@mainfrom the org's.githubrepo.If the org standard requires a different implementation (e.g. standalone logic instead of a reusable call, or different triggers/permissions), please refer to the ci-standards.md#required-workflows doc and adjust accordingly.
Steps to apply
.github/workflows/agent-shield.ymlwith the content above (needs a user or token with theworkflowsscope)mainor open a PR — the compliance audit should then passdon-petry commentedon Apr 7, 2026
Claude finished @don-petry's task in 1m 55s —— View job
Compliance Fix:
agent-shield.ymlRequiredagent-shield-reusable.yml@main.github/workflows/agent-shield.yml— file created and committed locallyworkflowspermission (same limitation as prior runs)Blocked:
workflowsPermission RequiredThe GitHub App token cannot push new
.github/workflows/files — this is a known limitation. Three separate Claude runs have now hit this same wall.@don-petry — manual action required. You need to create this file with a token that has the
workflowsscope (your personal PAT or direct push).File to create:
.github/workflows/agent-shield.ymlHow to apply
To resolve permanently: grant the GitHub App the
workflowspermission in repository settings so future compliance fixes can be automated.don-petry commentedon Apr 7, 2026
Claude finished @don-petry's task in 8m 50s —— View job •
claude/issue-74-20260407-1732• [Create PR ➔](https://github.com/petry-projects/broodly/compare/main...claude/issue-74-20260407-1732?quick_pull=1&title=Issue%20%2374%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%2374%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)Compliance Fix:
agent-shield.ymlRequiredclaude.ymlandfeature-ideation.ymlthin-caller patterns.github/workflows/agent-shield.yml(thin-caller pattern matching repo conventions)Self-Review
The file follows the thin-caller convention exactly — identical structure to
claude.ymlandfeature-ideation.yml:claude.yml/feature-ideation.ymlpermissions: {}at workflow level (least privilege)contents: read+pull-requests: writepull_requestonmain, all three standard types@main(consistent with other callers)secrets: inheritpresent for reusable workflowCI Results
The direct SonarCloud status context failure is pre-existing — this PR adds only a YAML workflow file with no source code, so it cannot affect code quality metrics.
| View PR
ci: add agent-shield.yml workflow
don-petry commentedon Apr 8, 2026
Claude finished @don-petry's task in 1m 12s —— View job •
claude/issue-74-20260408-2242• [Create PR ➔](https://github.com/petry-projects/broodly/compare/main...claude/issue-74-20260408-2242?quick_pull=1&title=Issue%20%2374%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%2374%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)Compliance Fix:
agent-shield.ymlRequiredpetry-projects/.github/standards/workflows/agent-shield.yml.github/workflows/agent-shield.ymlSummary
The
agent-shield.ymlfile was copied verbatim from the org standard template atpetry-projects/.github/standards/workflows/agent-shield.yml. It's a thin-caller stub delegating toagent-shield-reusable.yml@v1withcontents: readpermissions.CI is pending — once green, @don-petry can merge petry-projects/broodly#97 to close this issue.
•
claude/issue-74-20260408-2242ci: add agent-shield.yml workflow