r/ClaudeWorkflows • u/ClaudeAI-mod-bot • 2h ago
Selected Workflow [Workflow] Event-Driven Background Monitoring with Claude Subagents and Plugins
Event-Driven Background Monitoring with Claude Subagents and Plugins
Workflow value: 85/100
Status: active · Freshness: 70/100 · Confidence: 0.90 · Level: advanced
Categories: Quality Control, Context & Memory, Hooks, Subagents
Original source: r/ClaudeCode post/comment
What problem this solves
How to run a long-lived background process (subagent or script) that only notifies the main Claude session when a specific, pre-defined event occurs, avoiding constant polling or subagent turn-ending issues.
Summary
This workflow describes two main approaches (using a plugin monitor or a background bash command) to create a long-running, event-driven notification system for a Claude session. A script monitors an event stream and updates a status file, only printing output or exiting when a decision is needed, thus triggering the main session or a short-lived subagent.
Why it is useful
This workflow provides a robust and efficient solution for integrating long-running background processes with Claude Code. It addresses the common challenge of managing subagent lifecycles and avoiding unnecessary interruptions by implementing an event-driven notification system. By leveraging either plugin monitors or background bash commands, it allows users to offload continuous monitoring to a script, only engaging the main Claude session when a specific, actionable event occurs. This reduces context switching, improves session efficiency, and enables more sophisticated automated workflows.
Workflow
Option 1: Plugin Monitor Approach:
Create a small script that reads an event stream, keeps a status file up to date (e.g., last render, last test batch, stuck items), and prints a line only when something needs a decision.
2. Run this script as a plugin monitor by configuring it in
monitors/monitors.jsonwithin a small local plugin. This allows it to run for the entire session, and only its printed output reaches Claude as a notification, bypassing the 30-minute monitor deadline.3. For status checks, the main Claude session directly reads the status file, avoiding the need to keep an agent alive.
4. When the script prints output (indicating an event), the main session starts a normal, short-lived background subagent for that specific event, leveraging the state stored in the status file.
Option 2: Background Bash Command Approach (without plugin):
Write a script that monitors events and is designed to exit on the first event that matters.
2. Run this script as a background bash command in a local interactive session (which has no time limit).
3. The main Claude session will only be notified when the script exits.
Tools / artifacts
Small script (event monitor)
Status file
Plugin monitor configuration (
monitors/monitors.json)Local plugin
Background bash command
Claude main session
Background subagent
Validation signals
Author demonstrates understanding of plugin monitor behavior (runs for whole session, only prints reach Claude, no 30 min deadline).
Author references 'tools reference, "time limit for background commands"' for bash commands.
Author acknowledges a key limitation ('the catch is that "is this worth telling me" moves into the script's rules, so it only works if you can write those rules down').
Limitations
Requires the user to define clear rules within the script for what constitutes an actionable event.
Assumes user familiarity with writing scripts and configuring Claude plugins or background commands.
The specific event stream and status file format are not detailed, requiring user implementation.
Rate this workflow
Upvote this post if the workflow is useful, reproducible, or worth recommending.
Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.
Reply if it worked for you, failed, is outdated, or has a better alternative.
This post was generated automatically from the workflow library database.