precondition decides whether the agent runs on this repository at all. where decides which files it reviews.
The precondition gate
Omitprecondition and the agent always runs. Set it with a regex check, a prompt check, or both.
The
regex check runs first and costs nothing. When an agent declares both and the regex check does not match, the agent skips before it reaches the LLM call.
Regex sub-checks
Four sub-checks live underprecondition.regex. Any one match queues the agent.
Each
patterns entry sets regex, an optional label, and optional in and notIn glob lists. An empty in list means any file. No official agent uses directories today, but the schema and the evaluator both support it.
agentgg-agents/agents/mobile/ios-url-scheme.md. The regex check queues the agent for any Swift or Objective-C project. The prompt check narrows further with an LLM call.
The where scope
where sets the files an agent’s tool session starts from. The agent can still read more files with its Read, Glob, and Grep tools.
Agents with no file scope
An agent that declares noextensions and no filePatterns has no file
scope. It receives no candidate files and searches the whole repository itself
with its Read, Glob, and Grep tools, in a single session, so maxFilesPerBatch
and preFilter have nothing to narrow and do nothing. The 150 turn default
applies only when maxTurnsPerBatch is absent, so an agent that loses its
scope but keeps maxTurnsPerBatch runs on its own declared value instead.
excludePatterns still applies, together with --auto-exclude and the default
exclude set, so the agent is told to skip paths such as node_modules and
build output. A scoped agent reports the files it reviewed against a known
total. An unscoped one has no total to report against.
preFilter anchors
ApreFilter entry narrows the matched files further. A file becomes a candidate only when at least one entry matches a line inside it. The matching line numbers and labels pass to the model as anchors.
Semgrep rules as anchors
AsemgrepRule value is a bare name, never a path and never a registry identifier. The CLI resolves the name in this order: first the directories passed to --semgrep-rules, then the catalog’s own semgrep-rules/ folder. It matches <name>.yml or <name>.yaml in the first directory that has one.
agentgg-agents/agents/auth/missing-access-control-semgrep.md. The name resolves to agentgg-agents/semgrep-rules/http-endpoints.yml, a rule that finds a route handler declared by file position instead of a path string, a pattern a per-line regex cannot express.
A full example
agentgg-agents/agents/auth/js-nextjs-middleware-only-auth.md, trimmed. The precondition queues the agent only for a Next.js project with an exported route handler. The where scope hands the agent those same route files, with the export line as its anchor.
