agentleFS
PedroMeloOfficialPedroMeloOfficial/Youtube-Agent-Matrix/CLAUDE.md

Youtube-Agent-Matrix

CLAUDE.md11 starsChanged 9 days agoMITView on GitHub

Guidance for anyone (human or agent) editing this plugin. The user-facing document is README.md; this one is about how the thing is built and how to keep it coherent. The separation is the point. Routing logic that leaks into an agent makes the agent unusable on its own. Domain knowledge that leaks into the orchestrator gets loaded on every single request. Benchmarks that leak into either one start drifting the moment the platform changes. Which layer does a change belong…

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

22 rules. About 0 are common, 12 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    5. Agent frontmatter: Every file in agents/ opens with:

    line 82
  2. Very specific:

    6. Python scripts output JSON and degrade gracefully: Every script in execution/:

    line 98
  3. Distinctive:

    Never printed — not in full, not masked.

    line 110
  4. Distinctive:

    8. Stay generic: No person's name, no real channel, no assumed niche, no assumed market anywhere in the plugin.

    line 140
  5. Very specific:

    Create agents/<agent-name>.md with name: <agent-name> matching the filename stem.

    line 150
  6. Very specific:

    Write the description for routing: what it owns, then when to use it.

    line 151
  7. Very specific:

    If it belongs in the production chain, update the chain diagram in both SKILL.md and README.md, and decide explicitly whether it sits …

    line 163
  8. Distinctive:

    Do not add a fourth gate without a strong reason — gate count is a design budget.

    line 165
  9. Very specific:

    Read templates/channel-types/_schema.md first — it defines both the five classification axes and the normalized section order every …

    line 172
  10. Distinctive:

    Do not invent one to fill the template.

    line 184
  11. Very specific:

    Add it to the archetype list in _schema.md and to the folder map in README.md.

    line 185
  12. Distinctive:

    Update its date and source on the same line or in the section's source note.

    line 196
  13. Distinctive:

    If the number no longer exists in a trustworthy form, move it to §11 *Known gaps* rather than keeping a stale value.

    line 207
  14. Distinctive:

    Never let a competing figure survive in an agent, a template or another reference.

    line 210
  15. Very specific:

    Write unavailable rather than deriving: If no source gives that niche's RPM for this market, say so.

    line 231
  16. Distinctive:

    Same agent, same run: Never split the pair across two agents or two invocations — that is how they drift.

    line 290
  17. Distinctive:

    Derived files originate nothing: Every statement traces to the source.

    line 292
  18. Very specific:

    Agents decide, scripts calculate: No agent writes FCPXML, computes a frame or edits a script's output.

    line 324
  19. Very specific:

    The creator's media is read-only: Never moved, renamed, copied or deleted.

    line 333
  20. Distinctive:

    When a figure cannot be re-verified, downgrade its confidence tag or move it to §11 rather than leaving it looking fresh.

    line 358
  21. Distinctive:

    Keep §11 *Known gaps* honest and current.

    line 360
  22. Distinctive:

    Before any release, the short checklist:

    line 374

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md — Maintainer Guide

Guidance for anyone (human or agent) editing this plugin. The user-facing document is README.md; this one is about how the thing is built and how to keep it coherent.


Architecture: three layers

  Layer 1   skills/orchestrator/SKILL.md
            Routing, startup sequence, state, gates, delegation contract.
            Holds no domain knowledge and writes no deliverable.
                        │  delegates with an explicit prompt
                        ▼
  Layer 2   agents/*.md
            16 pre-production subagents. Each owns its deliverable — two of them
            also own a derived creator-facing view of it, see below. Agents do not
            call each other; the orchestrator fans them out and collects results.
            (+ skills/editor/SKILL.md and its 8 editing agents — see "Editing".)
                        │  loads, on demand, only what it needs
                        ▼
  Layer 3   references/*.md  +  templates/channel-types/*.md  +  templates/outputs/*
            Knowledge and shape. Inert: nothing here decides anything.
            execution/*.py sits beside this layer as optional live data.

The separation is the point. Routing logic that leaks into an agent makes the agent unusable on its own. Domain knowledge that leaks into the orchestrator gets loaded on every single request. Benchmarks that leak into either one start drifting the moment the platform changes.

Which layer does a change belong in?

The change is…It goes in
When something runs, in what order, who approvesskills/orchestrator/SKILL.md
How one deliverable is produced and what it must containagents/<agent>.md
A fact, a rule, a framework, a mechanicreferences/<topic>.md
A numberreferences/benchmarks.md, and nowhere else
Archetype-specific targets and patternstemplates/channel-types/<type>.md
The shape of a written deliverabletemplates/outputs/
Talking to an APIexecution/

Hard authoring rules

1. SKILL.md stays under 500 lines. It loads on every invocation. Anything that is not routing, state or gates belongs in a reference file. If it is growing, something has leaked down from Layer 3 or up from Layer 2.

2. Reference files stay under ~260 lines. They are loaded selectively and read in full when loaded. Past that, split by topic rather than letting one file become the place everything lands.

references/benchmarks.md is exempt from this limit, and it is the only exemption. Holding every number in the system in one file is the whole point of rule 3 below — splitting it by topic would manufacture exactly the second home for a number that rule 3 exists to prevent, and the first time the two copies drifted the system would start quoting a stale figure with full confidence. Its length is a consequence of the design, not a symptom of neglect. Keep it organized by numbered section instead: agents load it by section reference, not by reading it end to end.

3. All benchmark numbers live only in references/benchmarks.md. This is the rule the whole system's credibility rests on. No agent, no template, no other reference restates a CTR range, a retention target, an RPM figure, a character limit or a quota cost — they point at benchmarks.md instead. Two files holding the same number means one of them is already wrong; you just do not know which yet.

Grep before you commit:

grep -rniE '[0-9]+(\.[0-9]+)?\s*%|RPM|CPM' agents/ references/ templates/ \
  --include='*.md' | grep -v 'references/benchmarks.md'

Percentages that survive that filter should be structural (a weighting, a split, a share of a score), never platform data.

4. Kebab-case filenames throughout. hook-library.md, channel-auditor.md, niche-authority.md. Python files stay snake_case.py — a module name has to be importable.

5. Agent frontmatter. Every file in agents/ opens with:

---
name: agent-name          # MUST equal the filename stem: agents/agent-name.md
description: One sentence on what it owns, then one on when to use it. This is
             what the orchestrator matches against — write it for routing, not for a
             catalogue entry.
tools: Read, Write, Edit, Glob, Grep, WebSearch, WebFetch   # only what it needs
model: opus               # or sonnet for the lighter agents
---

name mismatching the filename is the most common breakage: the orchestrator delegates by name and the agent silently does not exist.

6. Python scripts output JSON and degrade gracefully. Every script in execution/:

  • has a module docstring covering purpose, cost, credentials and usage examples;
  • exposes --help via argparse;
  • prints JSON to stdout on success ({"ok": true, ...}) and on failure ({"ok": false, "error": {"code", "message", "fix"}}), exiting non-zero on failure;
  • never emits a stack trace — install_excepthook() from utils/youtube_auth.py converts anything uncaught into a JSON error object;
  • names the manual fallback in the error when a credential is missing, so the workflow continues without it;
  • reads credentials from environment variables and the user config directory (~/.config/youtube-agent-matrix/) only. Never from, and never written to, the plugin folder. Never printed — not in full, not masked;
  • checks utils/quota_tracker.py before an expensive call and records what it spent;
  • depends on nothing beyond the standard library plus google-api-python-client / google-auth-oauthlib, with one exception: build_reader_doc.py uses python-docx when it is present and falls back to pandoc, then to leaving the Markdown in place. An optional dependency is only acceptable when its absence degrades the output rather than blocking it.

Exception — execution/edit/. Video editing cannot run on the standard library. Scripts there may depend on ffmpeg/ffprobe and xmllint (system tools), numpy, mlx-whisper and faster-whisper (transcription, speech detection), opencv-python-headless (face tracking), and Node.js running a pinned hyperframes version through npx. They are listed in execution/edit/requirements.txt and installed into a dedicated virtualenv outside the plugin (~/.local/share/youtube-agent-matrix/edit-venv), never into the system Python, never inside the plugin folder, and only after the creator says yes (setup_check.py lists what is missing). Everything else above still applies: JSON on stdout, no stack traces, a module docstring, --help. "Degrade gracefully" means here: a missing dependency stops that editing step with the exact install command — it never affects pre-production, and no step silently falls back to a weaker method (a fallback that exists, like CPU transcription, is announced). Library modules in that folder (common.py, timebase.py, audio_tools.py, easing.py) have no CLI of their own.

Compile-check before committing:

python3 -m py_compile execution/*.py execution/utils/*.py execution/edit/*.py
python3 -m unittest discover -s execution/edit/tests      # needs ffmpeg + numpy

7. Everything is written in English. Source files, comments, docstrings, agent prompts. The creator's chosen language governs deliverables at runtime, never the repository.

8. Stay generic. No person's name, no real channel, no assumed niche, no assumed market anywhere in the plugin. Examples use placeholders. A channel-specific detail in a template is a bug — it will be wrong for every other user.


Adding a new agent

  1. Check it earns a slot. Does it own a deliverable no existing agent owns? Overlapping agents make routing ambiguous, and ambiguous routing is worse than a missing agent.
  2. Create agents/<agent-name>.md with name: <agent-name> matching the filename stem.
  3. Write the description for routing: what it owns, then when to use it. The orchestrator reads this and nothing else when deciding.
  4. Grant the minimum tools. Only agents that fan out internally need Agent. Only agents that run the execution layer need Bash.
  5. Name the reference files it should load, specifically. "Load what you need" makes an agent load all fourteen.
  6. State its output contract: exact filename, exact sections, where it writes in workspace/videos/<slug>/ or workspace/.
  7. Register it in three places, or it is invisible:
    • the agents table in skills/orchestrator/SKILL.md
    • the routing tables in skills/orchestrator/SKILL.md (command and/or natural language)
    • the agents table in README.md
  8. If it belongs in the production chain, update the chain diagram in both SKILL.md and README.md, and decide explicitly whether it sits before, after or inside an existing gate. Do not add a fourth gate without a strong reason — gate count is a design budget.
  9. Cite no numbers of its own. It reads benchmarks.md.

Adding a new channel archetype

Read templates/channel-types/_schema.md first — it defines both the five classification axes and the normalized section order every archetype file follows. Agents read any archetype the same way, and that only holds if the schema is followed exactly.

  1. Confirm it is a genuine archetype, not a niche. "Gaming" is an archetype (different traffic surface, cadence, format, monetization). "Cooking" is a niche — it is served by Tutorial or Personal Brand.
  2. Copy the section order from _schema.md. Do not reorder, rename or drop sections.
  3. Fill in what makes it different: traffic surface, viewer intent, cadence, typical length, title and hook patterns, monetization stack, production model.
  4. Numbers still come from benchmarks.md. If the archetype needs a target that is not there, either add it to benchmarks.md with a date and a source, or say the benchmark is unavailable. Do not invent one to fill the template.
  5. Add it to the archetype list in _schema.md and to the folder map in README.md.
  6. Sanity-check the classifier: describe two real-feeling channels of that type and confirm the five axes actually land on it rather than on an existing archetype.

Updating a benchmark

The value of benchmarks.md is that it is the only place a number lives. Protect that.

  1. Change the number in benchmarks.md only.
  2. Update its date and source on the same line or in the section's source note. A number with no date is unusable within a year.
  3. Set the confidence tag honestly: A multi-source or large-N, B single credible source, C directional or anecdotal. Downgrading a tag is a legitimate edit on its own.
  4. Grep the repository to make sure no second file picked the figure up:

    grep -rn '<the old number>' . --include='*.md' --include='*.py'

    Any other file holding it is the bug — remove it there, point at benchmarks.md instead.

  5. If the number no longer exists in a trustworthy form, move it to §11 Known gaps rather than keeping a stale value. "Benchmark unavailable" is a correct answer; a stale figure presented as current is not.
  6. Never let a competing figure survive in an agent, a template or another reference. One number, one home.

The one legitimate exception: the per-call quota costs in execution/utils/quota_tracker.py. Those are operational constants the code spends against, not figures the matrix cites. The headline quota numbers agents quote still come from benchmarks.md §10.


Adding a new market

Market files live in references/markets/, one per market code, plus _index.md. Read references/markets/_index.md before writing one — it is the schema: the frontmatter fields, the fixed ten-section body, the workspace/config.json → markets.mix config shape, the weighted-blending method, and the table of which agent reads which section. Agents cite section numbers, so do not reorder or renumber sections.

The hard rules, which are not negotiable:

  1. Every figure carries a confidence tag and a source. Market data is volatile and mostly C. A C labelled B is worse than no number at all.
  2. Write unavailable rather than deriving. If no source gives that niche's RPM for this market, say so. Multiplying the US figure and presenting the result as market data is exactly the fabrication this system exists to prevent — that is what the multiplier table is for, and it must be labelled as a multiplier.
  3. Never restate platform mechanics. CTR bands, retention thresholds, character limits, YPP requirements and quota costs live in benchmarks.md and are cited, never copied. A market file holds only what actually changes by country: economics, culture, law, rhythm.
  4. State the review date in last_reviewed, and date individual figures where they differ.
  5. Written in English, like every reference. Deliverables are translated; references are not.

Then: add the market to the Available markets table in _index.md, and — if it supersedes a row in localization-guide.md §2 — mark that row superseded rather than deleting it.

Market files decay faster than any other reference in this repo. Ad rates, sponsorship norms, payment rails and disclosure regimes all move within a year, and a stale market file is quoted with the same confidence as a fresh one. Re-review every market file at least yearly, and downgrade a confidence tag or write unavailable rather than letting a figure look current when it is not.


Localization rule

Every revenue figure in benchmarks.md is US-baseline. RPM, CPM, sponsorship rates, product pricing — all of it is United States, English-language, long-form unless a line says otherwise.

Any agent producing a revenue figure for a non-US channel or a non-English audience must adjust it first: through references/markets/<code>.md where that market has a file, and only otherwise through references/localization-guide.md's directional multiplier table, saying which it used. Unadjusted US RPM applied to an emerging market is wrong by five to twenty times, and a revenue projection wrong by that much is worse than no projection at all.

This applies to authoring too: when adding a revenue number to benchmarks.md, label the market it came from. If it is not US, say so on the line — otherwise the conversion is applied twice.

CTR and retention data are not regionally adjusted in this matrix. There is no reliable non-US dataset for them; benchmarks.md §11 lists that as a known gap, and it should stay listed rather than being filled in with guesses.


Derived creator-facing files

Two deliverables ship in two versions, and the distinction is load-bearing:

Source of truth (agents read this)Derived view (the creator reads this)Owner
script-{a|b|c}-*.mdscript-recording.docx — screenplay format: scene/cut headings, speaker cues, spoken linesscript-agent, recording mode
workspace/channel-profile.mdworkspace/channel-summary.docxchannel-strategist

research-report-agent's research-report.docx uses the same converter (execution/build_reader_doc.py) but is not a pair: nothing downstream reads research-report.md as a source of truth, so rules 1–3 below don't apply to it the way they apply to the two pairs above. Rules 4–6 (Word output, graceful degradation, never clobbering a hand-edit) still do.

Rules when touching either pair:

  1. Only the source is ever read by an agent. Nothing in the system may depend on a derived file. If you find an agent reading one, that is the bug.
  2. Same agent, same run. Never split the pair across two agents or two invocations — that is how they drift.
  3. Derived files originate nothing. Every statement traces to the source. A fact that exists only in the derived view is a gap in the source; fill it there.
  4. Derived views are Word documents. The agent writes Markdown to the template, runs execution/build_reader_doc.py on it, and the script renders the .docx and deletes the Markdown. The templates' conventions are functional, not stylistic: in the recording script a plain paragraph is a line to say and a > line is a line to do, and the converter renders them differently so they cannot be confused on camera. The converter is the only writer of a .docx, and every document is A4 portrait with 2.54 cm margins — it rewrites the page layout after either renderer and verifies it. No agent writes docx code or sets a page size; a document in any other layout is a bug in whatever produced it.
  5. The converter is optional, like every integration here. Without python-docx or pandoc the conversion fails, the Markdown stays as the deliverable, and the agent passes on the install command. It also never overwrites a document the creator has annotated — it compares the file's hash against .reader-docs.json and writes -v2 instead.
  6. script-recording.docx is generated only for the variant approved at GATE 2, never for all three. Generating three would triple the cost of the most expensive agent in the matrix for two files the creator will never open.

Adding a third pair is a real decision, not a freebie: every derived file is another thing that can fall out of sync. Do it only when asked.

Editing

/yt edit hands over to a second skill, skills/editor/SKILL.md, which runs on the main thread like the orchestrator: it talks to the creator, holds the editing state and runs checkpoints (not gates — the orchestrator keeps its three). It delegates one stage at a time to eight agents: footage-agent, cut-agent, edit-style-agent, motion-plan-agent, asset-agent, motion-render-agent, camera-agent, sound-agent. The orchestrator only routes to the editor; it does not list those agents.

The rules that keep it coherent:

  1. Agents decide, scripts calculate. No agent writes FCPXML, computes a frame or edits a script's output. All time goes through execution/edit/timebase.py (exact fractions, no floats).
  2. One writer per file, as everywhere: each stage owns its own folder under workspace/videos/<slug>/edit/; edit-state.json, deliveries and returns belong to the editor. The ownership table lives in skills/editor/SKILL.md.
  3. Craft vs taste. Craft lives in references/editing/ (constants marked "craft default, overridden by the edit profile" — they are not platform numbers, so rule 3 does not send them to benchmarks.md). Taste lives in the creator's workspace/edit-profile/. A craft learning from a creator reaches this repository through a maintainer, never at runtime.
  4. The creator's media is read-only. Never moved, renamed, copied or deleted; nothing written inside a .fcpbundle; deliveries versioned, never overwritten. No computer use to drive Final Cut.
  5. Final Cut delivery is validated with xmllint --dtdvalid against the DTD of the same FCPXML version, read from the installed app (never committed here — it is Apple's). Without it a delivery is reported unvalidated, never silently checked a weaker way. Layout, roles and time rules: references/editing/delivery-fcpxml.md. When Final Cut behaves differently than expected, copy what it exports; do not guess.
  6. Tests are never weakened to make something pass. execution/edit/tests/ must pass, with the DTD (FCPXML_DTD=…) before a release.
  7. Attribution. The workflow and craft guides are adapted from fluxo-de-edicao (MIT, Lucas Leite): every adapted file names its source at the top, and THIRD_PARTY_NOTICES.md carries the licence. Translate and adapt; never paste the original text.

Maintenance

Platform numbers decay. YouTube changes what it counts, how it counts it and what it rewards, and creator-blog figures propagate outdated numbers for years after the fact. Treat anything tagged 2024 or earlier as directional, not as a measurement — safe for framing a decision, not safe for a projection a creator will act on.

A sensible review pass:

  • Re-check §1 CTR, §2 retention and §9 monetization against primary sources annually. Prefer platform documentation and official help pages over roundups.
  • Re-check §10 analytics and quota limits whenever a script starts failing in a new way.
  • When a figure cannot be re-verified, downgrade its confidence tag or move it to §11 rather than leaving it looking fresh.
  • Keep §11 Known gaps honest and current. An accurate list of what the system does not know is worth more than a complete-looking list of half-sourced numbers, because it is what stops an agent from inventing one.

The Codex version

The plugin also ships for OpenAI Codex. The Claude Code files stay the single source of truth; codex/build_codex.py generates everything Codex needs from them — one TOML custom agent per agents/*.md (Claude model → Codex reasoning effort: opus → high, sonnet → medium; no Codex model pinned), each skill with a short "Running in OpenAI Codex" preamble, commands/yt.md as a $yt skill, and the two Codex manifests. Never edit a generated file and never bend a Claude file to suit Codex: if Codex needs something different, the generator's preamble is where it goes. Any change to an agent, a skill, the command or plugin.json needs a rebuild — the Codex tests fail until it is done.

Before any release, the short checklist:

python3 -m py_compile execution/*.py execution/utils/*.py execution/edit/*.py   # scripts compile
FCPXML_DTD=<path> python3 -m unittest discover -s execution/edit/tests      # editing tests pass
wc -l skills/orchestrator/SKILL.md skills/editor/SKILL.md   # each under 500
wc -l references/editing/*.md                               # each around 260 or less
wc -l references/*.md                                       # each around 260 or less;
                                                            # benchmarks.md exempt (rule 2)
grep -L 'name:' agents/*.md                                 # every agent has frontmatter
python3 codex/build_codex.py                                # regenerate the Codex version
python3 -m unittest discover -s codex/tests                 # Codex files current and valid

Then confirm each agent's name still equals its filename stem, and that any agent added or renamed appears in the orchestrator's tables (editing agents: in the editor's table) and in README.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.