Summary
When /brewcode:setup runs on a system without grepai configured,
the SessionStart hook correctly detects this:
SessionStart:startup says: grepai: not configured
Nevertheless, setup synchronizes .claude/rules/grepai-first.md into
the project. The rule contains a directive that every subagent reads:
FIRST grepai mcp for code exploration. Params → MCP descriptions.
Agents receive instructions to use a non-existent MCP server. This
pollutes every agent's prompt with a dead directive.
Root cause
brewcode/skills/setup/scripts/setup.sh (around lines 97-99):
# grepai-first: always sync (plugin-managed rule)
if [ -f "$PLUGIN_TEMPLATES/rules/grepai-first.md.template" ]; then
sync_template "$PLUGIN_TEMPLATES/rules/grepai-first.md.template" \
".claude/rules/grepai-first.md"
fi
The "always sync" comment is explicit: the script ignores grepai
availability. No grepai_configured helper exists anywhere in
setup.sh — grepai detection lives only in the SessionStart hook,
not in setup itself.
Environment
- Claude Code: v2.1.107
- Plugin: claude-brewcode 3.5.2
- OS: Windows 11 Pro, MSYS2 (grepai MCP not installed)
Reproduction
- Confirm grepai is not configured (SessionStart log shows
grepai: not configured).
- Run
/brewcode:setup.
- Open
.claude/rules/grepai-first.md — exists with live
directives referencing a missing tool.
Expected
Either:
- Skip syncing when grepai is not configured.
- Remove an existing
grepai-first.md if grepai becomes
unavailable between setup runs.
- Render the file with a conditional header: "This rule is inactive
because grepai MCP is not configured in this environment."
Proposed fix
Add a grepai detection helper to setup.sh. The SessionStart hook
already performs this check — the logic can be extracted or
duplicated:
grepai_configured() {
# Reuse the same detection the SessionStart hook uses.
# Adjust the concrete check to match the actual MCP registry
# location in your target environments.
[ -f "$HOME/.claude/mcp.json" ] && grep -q '"grepai"' "$HOME/.claude/mcp.json"
}
Then wrap the grepai-first.md sync:
if grepai_configured && [ -f "$PLUGIN_TEMPLATES/rules/grepai-first.md.template" ]; then
sync_template "$PLUGIN_TEMPLATES/rules/grepai-first.md.template" \
".claude/rules/grepai-first.md"
elif [ -f ".claude/rules/grepai-first.md" ]; then
rm ".claude/rules/grepai-first.md"
fi
The exact MCP config path may differ per environment — the author
knows the correct location better. The pattern is what matters:
check before sync, clean up on absence.
Impact
Low severity by itself — Claude usually recognizes the tool is
missing and falls back to native Grep. But the dead directive
pollutes every agent's prompt and undermines the credibility of
.claude/rules/ as a source of applicable guidance.
Summary
When
/brewcode:setupruns on a system without grepai configured,the SessionStart hook correctly detects this:
Nevertheless, setup synchronizes
.claude/rules/grepai-first.mdintothe project. The rule contains a directive that every subagent reads:
Agents receive instructions to use a non-existent MCP server. This
pollutes every agent's prompt with a dead directive.
Root cause
brewcode/skills/setup/scripts/setup.sh(around lines 97-99):The "always sync" comment is explicit: the script ignores grepai
availability. No
grepai_configuredhelper exists anywhere insetup.sh— grepai detection lives only in the SessionStart hook,not in setup itself.
Environment
Reproduction
grepai: not configured)./brewcode:setup..claude/rules/grepai-first.md— exists with livedirectives referencing a missing tool.
Expected
Either:
grepai-first.mdif grepai becomesunavailable between setup runs.
because grepai MCP is not configured in this environment."
Proposed fix
Add a grepai detection helper to
setup.sh. The SessionStart hookalready performs this check — the logic can be extracted or
duplicated:
Then wrap the grepai-first.md sync:
The exact MCP config path may differ per environment — the author
knows the correct location better. The pattern is what matters:
check before sync, clean up on absence.
Impact
Low severity by itself — Claude usually recognizes the tool is
missing and falls back to native
Grep. But the dead directivepollutes every agent's prompt and undermines the credibility of
.claude/rules/as a source of applicable guidance.