Skip to content

feat: add AgentShield CI standard and agent-shield.yml workflow template#25

Merged
don-petry merged 7 commits intomainfrom
feat/agent-shield-standard
Apr 6, 2026
Merged

feat: add AgentShield CI standard and agent-shield.yml workflow template#25
don-petry merged 7 commits intomainfrom
feat/agent-shield-standard

Conversation

@don-petry
Copy link
Copy Markdown
Contributor

@don-petry don-petry commented Apr 5, 2026

Summary

  • New standard: standards/agent-standards.md defines security and structural requirements for agent config files (CLAUDE.md, AGENTS.md, SKILL.md, .claude configs)
  • New workflow template: standards/workflows/agent-shield.yml is a reusable CI workflow that enforces the standard
  • Updated: standards/ci-standards.md now lists AgentShield as the 7th required workflow and includes it in the new-repo onboarding checklist

Why

The org already requires AGENTS.md and CLAUDE.md in every repo (the compliance audit checks for them), but there is no CI workflow that validates these files for security and correctness. Repos with BMAD modules or Claude plugins have agent config files that should be validated for secrets, permission bypasses, and structural integrity.

What the AgentShield workflow checks

Security rules (6)

Rule Severity
no-secrets — no API keys, tokens, passwords in agent configs error
no-skip-permissions — no dangerouslySkipPermissions bypasses error
no-unrestricted-tools — tool authorizations should be scoped warning
org-reference — AGENTS.md must reference org-level standards error
claude-reference — CLAUDE.md must reference AGENTS.md error
no-prompt-injection-vectors — no user-controllable template vars in security positions warning

Structural rules (3)

Rule Severity
valid-yaml-frontmatter — SKILL.md files must have valid frontmatter error
manifest-consistency — skill manifests must match directory structure warning
no-orphan-skills — skills must be registered in module-help.csv warning

Test plan

  • Verify the workflow YAML is valid by running it on a repo with CLAUDE.md and AGENTS.md
  • Test secret detection patterns against known safe and unsafe inputs
  • Confirm the ci-standards.md updates render correctly and numbering is consistent

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added repository-wide standards for AI agent configuration, requiring specific agent docs and mandatory cross-references between them.
    • Updated CI guidance to mandate an AgentShield validation workflow and updated onboarding checklist.
  • Chores

    • Introduced AgentShield compliance checks that enforce agent-doc presence, scan for secrets and permission-bypass patterns, and validate skill/document frontmatter and format.

Defines agent configuration security requirements (no secrets,
no permission bypasses, valid frontmatter, org references) and
provides a reusable workflow template for all repos.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 5, 2026 20:55
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2026

Warning

Rate limit exceeded

@don-petry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 43 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 43 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a454e007-52de-4bf4-91a4-996140cfde60

📥 Commits

Reviewing files that changed from the base of the PR and between c008b70 and 7fc8cb9.

📒 Files selected for processing (2)
  • standards/agent-standards.md
  • standards/workflows/agent-shield.yml
📝 Walkthrough

Walkthrough

Adds repository agent standards documentation and a new AgentShield GitHub Actions workflow; updates CI standards to require and document the AgentShield workflow that validates CLAUDE.md, AGENTS.md, SKILL.md frontmatter, secret/credential absence, and permission-bypass rules.

Changes

Cohort / File(s) Summary
Agent Standards Documentation
standards/agent-standards.md
New doc specifying required agent artifacts (CLAUDE.md, AGENTS.md), cross-reference rules, forbidden contents (secrets, permission-bypass patterns), and AgentShield validation scopes and severities.
CI Standards Update
standards/ci-standards.md
Updated onboarding and CI requirements to mandate 7 workflows and include AgentShield details (presence checks, secret scans, SKILL.md frontmatter validation, permission-bypass detection).
AgentShield Workflow
standards/workflows/agent-shield.yml
New GitHub Actions workflow triggered on push/PR to main that runs checks: required files present, cross-references exist, secret/credential pattern scans, permission-bypass detection, and SKILL.md YAML frontmatter validation; failing on error-severity findings.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    rect rgba(200,230,255,0.5)
    Actor Repo
    end
    rect rgba(200,255,200,0.5)
    Participant Actions as "GitHub Actions\n(AgentShield)"
    end
    rect rgba(255,230,200,0.5)
    Participant Scanner as "AgentShield\nscan/validators"
    end
    Repo->>Actions: push / pull_request to main
    Actions->>Scanner: run checks on files (`CLAUDE.md`, `AGENTS.md`, `SKILL.md`, .claude/*, etc.)
    Scanner->>Repo: read files (contents, YAML frontmatter)
    Scanner->>Scanner: validate cross-references, scan secrets, detect permission-bypass, validate SKILL frontmatter
    Scanner-->>Actions: report results (pass/warn/fail)
    Actions->>Repo: set workflow status (fail on error-severity findings)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately captures the main objective: introducing AgentShield CI standard and the agent-shield.yml workflow template, which are the primary changes across all three modified/added files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-shield-standard

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an AgentShield org standard plus a reusable GitHub Actions workflow template intended to enforce security/structure rules for agent configuration files, and updates CI standards to require the new workflow.

Changes:

  • Add standards/agent-standards.md defining required agent config files and validation rules.
  • Add standards/workflows/agent-shield.yml workflow template to enforce agent-file existence, references, secret scanning, permission-bypass detection, and SKILL.md frontmatter checks.
  • Update standards/ci-standards.md to list AgentShield as a required workflow and include it in new-repo onboarding.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
standards/workflows/agent-shield.yml New CI workflow template implementing AgentShield checks.
standards/ci-standards.md Documents AgentShield as the 7th required workflow and updates onboarding checklist.
standards/agent-standards.md New standard describing required agent files and the AgentShield rule set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread standards/workflows/agent-shield.yml
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/agent-standards.md Outdated
Comment thread standards/agent-standards.md Outdated
Comment thread standards/ci-standards.md
The bypass scan now skips lines that are documenting security rules
(negation patterns like "No ...", "Must not ...") and backtick-quoted
references to avoid false positives in AGENTS.md standards files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@standards/ci-standards.md`:
- Around line 11-14: The compliance script's REQUIRED_WORKFLOWS array in
scripts/compliance-audit.sh still lists only six workflows; add
"agent-shield.yml" to the REQUIRED_WORKFLOWS variable so the script enforces the
new 7-workflow standard (locate the REQUIRED_WORKFLOWS declaration in
scripts/compliance-audit.sh and append "agent-shield.yml" to the array, update
any related counts/validation logic that assumes six workflows).

In `@standards/workflows/agent-shield.yml`:
- Around line 43-48: The workflow step "Validate AGENTS.md references org
standards" is currently emitting a non-blocking ::warning; change it to fail the
job to match the documented "error" severity by emitting ::error and exiting
non-zero when the org reference is missing: update the run block inside the step
to use echo "::error file=AGENTS.md::..." (or both echo plus exiting) and call
exit 1 (or set status=1) when the grep check fails; alternatively, if you prefer
to keep it as a warning, update the documented severity in
standards/agent-standards.md (the org-reference rule) to "warning" so docs and
the step stay consistent.
- Around line 70-77: The for-loop building the file list using command
substitution with $(find ...) causes word-splitting and breaks on filenames with
spaces; replace that loop with a null-delimited safe iteration using find
-print0 piped into while IFS= read -r -d '' file; do ... done (or use find ...
-print0 | xargs -0 -n1 -I{} sh -c '...'), keeping the same inner checks (test -f
"$file", the grep invocation checking
'dangerouslySkipPermissions\|skipPermissions\|--dangerously', the error echo
that references $file, and setting status=1) so you avoid splitting filenames
and preserve the existing logic around file, grep and status.
- Around line 93-99: The frontmatter extraction using sed ('sed -n
'1,/^---$/p'') incorrectly matches the opening delimiter and yields an empty
frontmatter; update the extraction for the frontmatter variable to read the
lines between the first and second '---' delimiters (not including the
delimiters) — replace the current sed invocation that sets frontmatter with a
command that correctly extracts the block (for example use an awk-based
extraction that skips the first '---' and prints until the next '---'), keeping
the same variables (frontmatter and file) and preserving the existing
empty-check logic that emits "::error file=$file::SKILL.md has empty
frontmatter" and sets status=1.
- Around line 55-62: The for-loop over find output will break on filenames with
spaces; replace the "for file in CLAUDE.md AGENTS.md $(find ...)" loop with a
null-delimited safe iteration: use find ... -print0 and a while loop such as
"while IFS= read -r -d '' file; do ... done < <(find ... -print0)" so each
filename (including spaces) is read into $file safely; keep the inner checks (if
[ -f "$file" ]; then and grep -Pn "$patterns" "$file" ...) and preserve setting
status=1 and the error echo.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 497d8435-ed4e-46f5-a7d9-8e9773f20c00

📥 Commits

Reviewing files that changed from the base of the PR and between 788df7d and d9b3870.

📒 Files selected for processing (3)
  • standards/agent-standards.md
  • standards/ci-standards.md
  • standards/workflows/agent-shield.yml

Comment thread standards/ci-standards.md
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/workflows/agent-shield.yml Outdated
Comment thread standards/workflows/agent-shield.yml Outdated
…tter, severity alignment

- Add header comment to workflow template
- Mask secret values in logs (report count, not content)
- Use while-read loops instead of for-$(find) to handle paths with spaces
- Expand permission bypass scan to all src/ and .claude/ files
- Fix frontmatter extraction to use closing delimiter correctly
- Promote org-reference check from warning to error
- Mark planned-but-unimplemented rules as "Planned" in standards doc

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@standards/workflows/agent-shield.yml`:
- Around line 143-153: The script computes closing_line relative to tail -n +2
but then uses it as an absolute line number when extracting frontmatter, causing
off-by-one truncation; fix by converting closing_line back to the file's
absolute line number (e.g., add 1) or by extracting frontmatter using the same
relative indexing (use tail/sed consistently) so that frontmatter=$(sed -n
"2,$((closing_line))p" "$file" ) references the correct range; update the logic
around closing_line and the frontmatter extraction in the section that sets
closing_line and frontmatter to ensure the delimiters and content are captured
correctly.
- Around line 131-173: The workflow step "Validate SKILL.md frontmatter"
currently only checks YAML frontmatter (using the find . -name 'SKILL.md' loop
and status variable) but does not enforce the documented no-orphan-skills rule;
add a new non-blocking check after frontmatter validation that collects the list
of skill directories (from the same find of SKILL.md files), reads module names
from module-help.csv, compares them, and emits a warning (echo "::warning
file=...::...") for each SKILL.md whose directory is not listed in
module-help.csv; ensure this check does not set status to 1 so it remains
warning-only and reference the existing find/loop and module-help.csv when
implementing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 882978cb-b750-468a-848b-c268ad8a4b3a

📥 Commits

Reviewing files that changed from the base of the PR and between d9b3870 and c008b70.

📒 Files selected for processing (2)
  • standards/agent-standards.md
  • standards/workflows/agent-shield.yml

Comment thread standards/workflows/agent-shield.yml
Comment thread standards/workflows/agent-shield.yml Outdated
DJ and others added 3 commits April 5, 2026 14:36
Replace custom secrets/permission shell scripts with the real
AgentShield GitHub Action (v1.4.0) which provides 102 rules across
secrets, permissions, hooks, MCP servers, and agent config review.

Keep org-specific structural checks (required files, cross-references,
SKILL.md frontmatter) as a second layer for petry-projects conventions
not covered by the generic scanner.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The action's dist bundle has a missing yaml dependency. The CLI
(ecc-agentshield) via npx works correctly and provides the same
102-rule security scan.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CLI exits non-zero on critical findings automatically (exit code 2).
The --fail-on-findings flag only exists in the GitHub Action inputs,
not the CLI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 5, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants