Repository navigation
Backlog
Labels
difficulty: mediumLeaderboard: 6 points when the PR closing this is mergedenhancementNew feature or requesthelp wantedExtra attention is needed
Description
Part of #240. Builds on #242 (secfoo hook / secfoo automations) and #241 (every run reports back). Packaging: #225 / PR #230 (Claude plugin). This is the reference implementation. Other tools copy its structure.
What Claude Code offers (checked against the docs on 2026-12-03)
Sources: Hooks reference, Plugins reference. Re-check them and record the Claude Code version you test with.
- Hook config:
~/.claude/settings.json(user),.claude/settings.json(project, shared),.claude/settings.local.json(project, private), managed policy, pluginhooks/hooks.json, and skill/subagent frontmatter. - Events we need:
PreToolUse(matcherBash): block withhookSpecificOutput.permissionDecision: "deny"plus a reason.PostToolUse(matcher on the edit tools): informational.Stop:decision: "block"+reasonmakes Claude keep going. The input hasstop_hook_active, and Claude Code overrides the block after 8 consecutive continuations.SessionStart: inject context.SessionEnd: all hooks share a 1.5 s budget.
- Timeouts:
timeoutin seconds, default 600 for command hooks. - Background:
"async": trueruns without blocking.asyncRewakeruns in the background and wakes Claude on exit code 2, showing stderr as a reminder. That's ideal for slow reviews. - Env:
CLAUDE_PROJECT_DIR,CLAUDE_PLUGIN_ROOT,CLAUDE_PLUGIN_DATA,CLAUDE_PLUGIN_OPTION_<KEY>(pluginuserConfig). - Plugins:
.claude-plugin/plugin.json(onlynamerequired). Components at the plugin root:skills/<name>/SKILL.md,agents/,hooks/hooks.json,.mcp.json,bin/. Validate withclaude plugin validate. - Hooks run in
claude -pand inside subagents, including plugin and user hooks. This matters for the recursion guard (see Gotchas). - Scheduled / cloud: Claude Code cloud scheduled tasks (
/schedule), plus the existing secfoo GitHub Action for CI.
Recipe mapping
| Recipe | Claude Code event | Behaviour |
|---|---|---|
commit-guard |
PreToolUse, matcher Bash, command matches git commit/push, gh pr create |
Deny with the findings summary when at or above the threshold. Over budget → allow + background |
turn-review |
Stop |
If files changed this turn, review the diff. Findings at or above the threshold → decision: "block" with the findings so Claude fixes them. Respect stop_hook_active and #242's loop guard |
dependency-watch |
PostToolUse on edits to manifests/lockfiles, asyncRewake: true |
Background SCA. Wake Claude only if a reachable High+ appears |
design-review, ai-feature-review |
PostToolUse on matching paths, async: true |
Background, debounced, surfaced on the next Stop / SessionStart |
session-brief |
SessionStart |
Inject open High+ findings for this repo from the local DB. No run, must take under 1 s |
session-flush |
SessionEnd |
Only spawn the detached outbox flush and mark pending host-mode runs not_submitted. Never push inline: the budget is 1.5 s |
fix-findings |
Plugin skill /secfoo:fix-findings |
List open findings, fix them, re-run to confirm closure |
scheduled-baseline |
Cloud scheduled task | Prompt that installs secfoo and runs a full baseline with the key from the task's env (#241 item 4) |
Gotchas
- Recursion: secfoo's
claudeadapter runsclaude -p … --setting-sources user(src/secfoo/agents/claude.py). User and plugin hooks still load there, so adelegaterun would fire secfoo's own hooks again. Implementsecfoo hook+secfoo automations: one tested entrypoint for every AI tool, recipes enabled on the fly #242'sSECFOO_AUTOMATION_DEPTHguard. Also evaluate passing--settings '{"disableAllHooks": true}'to nested runs. It is documented for scripted-pruns, but managed hooks are unaffected. - Other tools read Claude's files: Copilot and Devin read
.claude/settings.json, and Grok Build setsCLAUDE_PROJECT_DIR. Host detection and de-duplication fromsecfoo hook+secfoo automations: one tested entrypoint for every AI tool, recipes enabled on the fly #242 must handle this. Add a fixture where a Claude-format entry is invoked by another host. - Admins:
allowManagedHooksOnlyanddisableAllHookscan turn our hooks off.secfoo automations doctor --tool claude-codeshould detect and explain this.
Install on the fly
- CLI:
secfoo automations enable turn-review --tool claude-code --scope project. - Plugin (Claude plugin: install Secfoo from the Claude Code marketplace (plus Desktop extension and claude.ai connector), local or with an API key #225): ship the recipes in
hooks/hooks.json, off by default. Add a/secfoo:automationsskill that runssecfoo automations enable/disablefor the current repo, so users switch recipes on from inside Claude Code.
Tasks
-
hosts/claude_code.pyparse/render with recorded fixtures forPreToolUse,PostToolUse,Stop(with and withoutstop_hook_active),SessionStart,SessionEnd -
enable/disablemerge into the three settings files without touching other hooks - Plugin bundle hooks generated from recipes (Secfoo in every agent marketplace: one MCP server, local by default, optional key for the org portal #224 build step) +
/secfoo:automationsand/secfoo:fix-findingsskills - Recursion guard verified with a real nested
claude -prun - Cloud scheduled task example in
docs/automations.md, using the env-var key - Verification row (Claude Code version, date, OS, recipes tested, portal received each run with
trigger.host = "claude-code")
Done when
All recipes above work against a real Claude Code install. Every run, including blocked, skipped, failed and timed-out ones, appears in secfoo serve and, with a key, on the portal with the correct trigger. The fixtures are in CI and the docs are written.
Metadata
Metadata
Assignees
Labels
difficulty: mediumLeaderboard: 6 points when the PR closing this is mergedenhancementNew feature or requesthelp wantedExtra attention is needed
Activity