The rapid acceleration of AI capabilities has transformed how teams manage information, yet keeping pace with the flood of updates remains a persistent challenge. Many organizations have turned to lightweight agent automations that run on a schedule, silently gathering context from Slack, GitHub, and other tools, then delivering concise briefings directly to the channels where decisions are made. While the promise of these background helpers is clear, building them reliably proves surprisingly difficult: agents can lose credentials, miss updates due to timing windows, or inadvertently repeat information, eroding trust in the very system designed to reduce noise. This guide walks through a battleโ€‘tested reference implementation that addresses these pitfalls headโ€‘on, offering a concrete blueprint for developers who want to ship dependable, selfโ€‘healing automations without managing infrastructure.

At the core of the solution lies Claude Managed Agents, a beta service that treats an agent as a versioned configuration rather than a longโ€‘lived process. Instead of provisioning servers or writing custom schedulers, you declare the agentโ€™s model, system prompt, tools, and memory layout in plain text files. The platform then spins up a fresh sandbox for each run, executes the defined steps, and tears the environment down, guaranteeing isolation between executions. This model eliminates whole classes of bugs caused by lingering state, while still giving the agent the ability to remember critical information across runs via mounted memory stores. For teams accustomed to traditional cron jobs or cloud functions, the shift to a declarative, configurationโ€‘first approach reduces operational overhead and improves reproducibility.

Security is a primary concern when an agent needs to read from Slack and write back to it, especially when those actions involve privileged tokens. The reference implementation solves this by isolating credentials in a vault that lives outside the agentโ€™s sandbox. When the agent references a secret, it uses an opaque placeholder such as $SLACK_BOT_TOKEN; the platform transparently swaps in the real value only when the request leaves the sandbox and targets an allowed host. This separation means that even if the agentโ€™s code is compromised or misbehaves, the actual token never touches the execution environment. Vaults are created with the ant CLI, populated via the TypeScript SDK, and then linked to the deployment, providing a clear audit trail of which secrets are in use and where they originate.

Integrating with diverse services requires a uniform way to call external APIs without forcing the agent to manage complex authentication flows. For GitHub, the implementation leverages MCP (Modelโ€‘Contextโ€‘Protocol) servers that run as proxies beyond the sandbox. The agent invokes MCP tools through this proxy, which looks up the matching credential in the vault and forwards the request. Because the proxy handles authentication, the agent can be granted blanket permission to call the GitHub toolset (set to always_allow) while still benefiting from readโ€‘only token restrictions. Slack, by contrast, is accessed directly via the bash tool and curl inside the sandbox; the same placeholderโ€‘swap mechanism applies, allowing the agent to both read channels and post messages without ever seeing the raw token in its filesystem.

One of the most subtle bugs in scheduled data pulls stems from using fixed time windows like โ€œthe last 24 hours.โ€ If a run is delayed, new events that arrived during the gap are missed; if it runs early, items from the previous cycle are resent, creating noise and duplication. The reference implementation replaces static windows with perโ€‘source bookmarks. At the end of each execution, the agent writes the timestamp of the newest item it processed from each source into a shared bookmarks.json file. The next run reads these timestamps and treats them as the lower bound, dynamically expanding or contracting its query range to cover exactly what changed since the last successful invocation. This selfโ€‘adjusting window guarantees completeness and eliminates repeat work, regardless of schedule drift or temporary pauses.

Even with robust bookmarking, external dependencies can failโ€”APIs go down, tokens expire, or network issues interrupt connectivity. Rather than letting a single sourceโ€™s outage corrupt the entire briefing, the agent is instructed to treat failures gracefully. If the GitHub MCP server is unavailable or its credential is invalid, the run still starts, the tools for that source are simply absent, and the session logs an error. The agent proceeds to gather what it can from Slack, constructs a brief from the available data, and appends a clear notice such as โ€œpull requests unavailable this run.โ€ This transparency informs readers that the omission is due to a technical hiccup, not a lack of new activity, preserving trust and enabling quick diagnosis.

Posting the generated brief back to Slack introduces another set of reliability concerns: ensuring the message is delivered exactly once and not duplicated due to uncertain acknowledgments. The implementation adopts three defensive rules in agent.md. First, before sending, the agent scans the target channelโ€™s recent messages for a headline matching todayโ€™s date; if it finds an identical post, it aborts to prevent duplication. Second, it considers the send successful only when Slackโ€™s response payload includes โ€œokโ€: true and a message timestamp (ts). Third, the agent updates its internal ledger of reported items and advances its bookmarks only after receiving that confirmed success. If the response is ambiguousโ€”perhaps a network timeoutโ€”the run is marked โ€œmaybe posted,โ€ the ledger and bookmarks remain untouched, and no data is lost or spuriously repeated. This idempotent pattern mirrors best practices from distributed systems and guarantees exactlyโ€‘once semantics despite the inherently unreliable nature of HTTP.

Operational visibility is essential for any background automation, and the agent provides it through a lightweight run log stored in the same memory store used for bookmarks. Each execution creates a file named runs/<date>.md, which the agent populates with a short narrative: it marks the run as โ€œpostingโ€ just before the Slack request, then updates it to โ€œpostedโ€ with the returned message ID upon confirmation, or to โ€œmaybe postedโ€ if the outcome is unclear. Over time, these logs form an audit trail that can be queried to detect missed runs, diagnose performance bottlenecks, or verify compliance with internal SLAs. Because the log lives in the platformโ€‘managed state folder, it persists between runs without requiring external databases, yet remains accessible to the agentโ€™s file tools for reading and appending.

The agentโ€™s behavior is shaped primarily by agent.md, which combines a declarative frontmatter with imperative instructions in the body. The frontmatter specifies the model (typically Claudeโ€ฏ3โ€ฏHaiku or Sonnet for costโ€‘efficiency), the enabled tools (bash for Slack, MCP for GitHub), and any external servers. The body contains concise directives: read sources according to preferences, apply exclusions, enforce a length cap, and, crucially, reโ€‘check the live status of each item just before posting to catch changes that may have occurred during the agentโ€™s processing window. By steering the model toward brevity and explicit verification, the prompt reduces the likelihood of hallucinated summaries or outdated information slipping into the final brief.

Deployment configuration lives in deployment.md, where you bind the agent to its environment, schedule, memory stores, vault, and budget. The schedule uses standard cron syntax, while a dedicated timezone field ensures the agent interprets dates in the correct region, avoiding the common bug where a run stamps โ€œyesterdayโ€ because it defaulted to UTC. The file also references the previously created vault ID and lists the two memory storesโ€”preferences (readโ€‘only) and state (readโ€‘write). Launching a test run outside the scheduled cadence is as simple as invoking ant beta:deployments run –deployment-id <id>, using the identifier recorded in claudeโ€‘lock.json after the initial apply. This immediacy lets developers validate changes rapidly without waiting for the next cron tick.

Memory stores separate concerns to prevent stale data from corrupting decisionโ€‘making. The preferences store holds the userโ€‘curated list of Slack channels, GitHub repositories, notification length limits, destination channel, and optโ€‘out rules; it is mounted readโ€‘only so the agent cannot accidentally overwrite it. The state store, conversely, is the agentโ€™s private workspace: it contains bookmarks.json, ledger.md (a running tally of every reported item with timestamps, source IDs, and last known status), perโ€‘run logs, and any notes the agent keeps about source quirks (e.g., โ€œGitHub returns only the newest 50 itemsโ€). By requiring the agent to read preferences fresh each executionโ€”rather than baking them into the promptโ€”the system avoids applying outdated filters after a user updates their configuration, a frequent source of confusion in promptโ€‘based agents.

Running agents continuously on a schedule introduces cost and safety considerations that are often overlooked in early prototypes. The reference implementation enforces strict limits: the GitHub token and preferences store are marked readโ€‘only, the outbound network allowlist includes only slack.com and api.github.com, and the agent lacks any write permissions to GitHub or the ability to alter its own rules. These sandbox controls mitigate promptโ€‘injection risks where malicious text in a Slack message could otherwise coax the agent into performing unwanted actions. Additionally, a budget cap in deployment.md caps the computational spend per run; setting it initially at three to five times the expected cost provides a safety net, and observing actual usage lets you tighten the threshold over time. If a run hits the cap, it pauses with a budget_reached signal rather than failing catastrophically, making the degradation visible and allowing operators to intervene before the automation goes silent.

Putting it all together, the six guiding principles distilled from this reference implementation are: (1) isolate secrets in a vault with placeholderโ€‘swap semantics; (2) use perโ€‘source bookmark windows instead of fixed time intervals; (3) handle source failures transparently without aborting the whole run; (4) enforce idempotent posting via preโ€‘checks, strict success criteria, and conditional state updates; (5) maintain detailed, selfโ€‘describing run logs for observability; and (6) enforce leastโ€‘privilege sandboxing, readโ€‘only defaults, and spend caps to guarantee security and costโ€‘control. By following these rules and leveraging the provided claudeโ€‘api skill in Claude Codeโ€”which scaffolds the necessary files and provisions resources with a single ant applyโ€”teams can move from fragile adโ€‘hoc scripts to robust, selfโ€‘healing agent automations that reliably deliver the right information at the right time, freeing humans to focus on higherโ€‘order work.