--- name: Swan --- ## Description How to run the tune-up from a client connected to the Swan MCP, and how to apply the changes through Swan's files and tools. ## Prerequisites - The Swan connector attached to this client, as an admin or a builder of the organization. - Call swan-get-guide once at the start; it explains the files and the two ways to work. - A client with code execution or sub-agents makes the inventory faster, but the skill works in plain chat by taking one agent at a time. ## Read order 1. `swan-get-subscription`: plan, pricing version (v1 per action, v2 data and intelligence), credits total, used and remaining, renewal date. The pricing version decides the fee table for every spend check (references/credits-and-pricing.md). Use the plan to scale thresholds. The page never warns about the credit balance or the renewal date. Then `swan-get-usage` for the last 30 days by automation, by teammate and by day. 2. `fs-read-file /brain/SWAN.md`: the organization's rules and focus. 3. `fs-shell ls /agents/org /agents/personal`, then for each agent `fs-read-file .../AGENT.md` (goal, KPIs, tools, skills, reviewEveryDays) and `fs-read-file /brain/agents/{scope}/{agent}/HEARTBEAT.md` for the last three reviews (date, headline, blockers, changes: what the agent re-enabled or created on its own). Then `fs-shell ls .../automations` and the frontmatter of every `AUTOMATION.md` in one call per agent (`fs-shell head -20 .../automations/*/AUTOMATION.md`): id, enabled, trigger type and settings, cron. Read the body only for automations the catalog flags, and read the first 2,500 characters first; most bodies state their purpose, trigger and stops there. 4. `swan-search-executions` with `filters.agentId`, `startDate` 30 days ago, no query: the aggregation gives runs, completed, failed and last run per automation. It counts child runs with their parents; say "runs" for the aggregation and "parent runs" when you read individual runs. Count from the aggregation, never by paging. Repeat with `runStatus: FAILED` only for agents with failures. Sequences with no automation behind them are the chat source; split each Campaign by source, and read three sequences of the top five Campaigns to name the play (a personal default Campaign can hide the winner). 5. `swan-get-outreach-analytics` for the last 30 and the last 90 days: `bySenderAndTrigger` gives contacted sequences and positive outcomes per automation; `byCampaign` per Campaign. Never sum sender rows. 6. `swan-search-sequences` with status `AWAITING_APPROVAL` and `STOPPED_AWAITING_APPROVAL`: count the backlog and its age. `swan-get-org-senders`: which senders have `requiresApproval` and which are disconnected. 7. `swan-get-record-lists`, then `swan-query-records`: `SELECT value, COUNT(*) FROM companies$tags GROUP BY value ORDER BY 2 DESC LIMIT 50` for the tag census, and the list entry counts. 8. `fs-shell ls -R /skills/org | head`, `wc -c` on each SKILL.md; `fs-read-file /brain/agents/{scope}/{agent}/MEMORY.md` sizes with `fs-shell wc -c`. 9. `swan-search-tickets` open: how many wait on a person, how old, and how the closed ones closed (answered, expired, dismissed), grouped by the agent or automation on the ticket. 10. Accepted requests with no message: `swan-search-sequences` for finished sequences whose connection was accepted and that sent no message; count them per sender (check W5). 11. `swan-get-integrations-status`: connected tools, expired ones. A CRM that answers errors while automations still run against it is check D9. Credits per automation come from `swan-get-usage` (same numbers as the usage page): `groupBy: automation` for the last 30 days gives credits, runs, credits per run and last run per automation; `groupBy: teammate` gives chat spend per person; `groupBy: day` shows when spend jumped; `groupBy: run` lists the costliest runs. The tool returns `pricingVersion`, and when the window holds both versions it adds `pricingChangedAt` and `creditsV1` / `creditsV2` beside every `credits`; read each side on its own and never add the two. Call it once per grouping; it is the second org-level read after the subscription. When the server does not offer it yet, fall back to `swan-fetch-execution` on the last five runs of each flagged automation and give the spread. A completed run on an event trigger that cost 1 to 2 credits and ends in "no change" or "not relevant" is a discarded event: count them, that is check B6. The run aggregation counts child runs with their parents; say so when you compare. When the connector has no `swan-get-usage`, take runs per automation from the `swan-search-executions` aggregation and the credits used in the period from `swan-get-subscription`. Rank automations by runs, and say on the page that credits per automation were not available. ## Backup before any change Create `/brain/workspace/org/_system/tune-up/{YYYY-MM-DD}/`. Before you change or delete a file, copy it there with `fs-read-file` and `fs-write-file` under the same relative path. Write `RESTORE.md` in the folder: for each changed file, the original path and the copy. Deleting an agent removes its folder under `/agents`; restore by writing `AGENT.md` back (new id) and moving its automations back with `fs-move-file`. ## Applying changes - Goals and KPIs: `fs-edit-file` on `goal` and the KPIs section in `AGENT.md`, with the numbers the team edited. Quote a goal that contains a colon; the AGENT.md check rejects it unquoted. - Give an outbound agent its playbook (W9): the connector cannot read Swan's agent library, so ask Swan with `send-message`, one agent per message: "Give the {agent} agent the agent library's playbook for {kind}. Read /system/agent-library/{library agent}/SKILLS.md and install each skill it lists, as the 'Build from the agent library' steps say; skip a skill that /skills/org already has by title. Add the installed skills to the agent's AGENT.md and add the library agent's experiment rules. Keep the agent's goal, its own rules and its automations. Change nothing that sends." Library agents for outbound: `signal-led-selling`, `targeted-outreach`, `abm`, `win-back`. Then read the agent's AGENT.md back with `fs-read-file` and confirm the new skills are listed. - Pause or resume an automation: `fs-edit-file` on `enabled: true|false` in its `AUTOMATION.md`. - Slow a review cadence: `fs-edit-file` on `reviewEveryDays` in `AGENT.md` (1 to 30). - Move an automation to another agent: `fs-move-file` of its folder into `/agents/{scope}/{agent}/automations/`. It keeps its id, webhook and history. - Merge agents: write the target `AGENT.md` first (goal, union of tools and skills), move the automations, write one consolidated `MEMORY.md` from the sources (see references/merge-and-consolidate.md), move notes and experiment files with `fs-move-file`, then delete the empty source agents with `fs-delete-file` after the yes. - Replace a scheduled monitor with a signal watch: write a new `AUTOMATION.md` with `trigger.type` set to the signal family (for example `workforce_changes` or `funding_and_financials`; the bare `BUSINESS_EVENT` is refused) or `WEBSITE_CHANGE` as references/signals-instead-of-schedules.md shows, enabled, with the companies source (domains, a CRM list, or company filters such as tag ids) and `eventCriteria` in prose. Pause the schedule; delete it only after the signal watch has fired once. - Turn a tag into a list: `swan-upsert-record-list` with the entry attributes the team needs (status, owner, next step, date), then `swan-update-list-entries` in batches of 100 from `SELECT id FROM companies WHERE ... tags`. Keep the tag while any trigger uses it as a company filter. - Automatic sending: edit the automation body to say sends go out without approval with a daily cap, and keep `AGENT.md` consistent; a sender with `requiresApproval` still holds everything. - Delete an automation or an agent: `fs-delete-file` on the folder, only after the proposal's yes, and only after the backup copy exists. ## Read-back After each change read the file again. For a moved automation, confirm its id is unchanged. For a new signal watch, read its `trigger-state.json` after the first sync for `enrolledDomains` and `capped`. For a list, query its table for the entry count. ## Success criteria - Every agent's goal has a number and a period, and every KPI counts the goal's result. - The proposal has at most five changes and every change names credits per month and the number it should move. - The organization ends with at most one agent per kind of work and no automation that has not run in 30 days still enabled. - A dated rollback folder exists and restores every changed file. - A summary file at `/brain/workspace/org/_system/tune-up/{date}/SUMMARY.md` holds the baseline numbers for the next tune-up. ## Recommended companion skills - Swan's own `building-agents-and-automations` and `diagnosing-an-automation` (read through swan-get-guide) for any rewrite or failing run. - The agent library under `/system/agent-library` for the methods an agent does not run yet.