The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Building a read-only Apex PMD and security reviewer agent in GitHub Copilot (opens in a new tab)

You will learn how to define a Copilot custom agent that audits Apex for PMD and OWASP-style security issues inside the IDE, without external integrations.

Why read this

You will also see the review output format and the tool restrictions that keep the reviewer read-only.

The article argues that static analysis of Apex usually runs too late, in a CI pipeline that fails a pull request after the developer has finished the work. In locked-down enterprise orgs, adding external AI review bots or webhooks is often blocked by security approval, so the author proposes a review agent that stays inside the existing GitHub Copilot boundary.

The agent is a declarative Markdown file, a .agent.md, stored in .github/agents/ for team sharing or in ~/.copilot/agents/ for personal use. It has a YAML header that gives its name, description and permitted tools, here restricted to search and fetch so the agent cannot modify files. The body is a system prompt that lists the rules to check, such as ApexCRUDViolation, ApexSOQLInjection, OperationWithLimitsInLoop and AvoidHardcodingId, grouped by security, performance, architecture and test quality.

The author gives a sample service class with a concatenated dynamic SOQL string, no sharing keyword, no user-mode enforcement and a DML statement inside a loop. The agent reports each issue with a severity, the rule name, the file and line, a short explanation and a compliant fix. The article closes with three team practices: keep shared conventions in copilot-instructions.md, restrict reviewer tools to read and search, and keep deterministic Salesforce Code Analyzer runs in the pull-request pipeline for audit trails.

Read the original at dev.to (opens in a new tab)

Worth reading?