pub const BASE_AGENT: &str = include_str!("assets/agents/BASE-AGENT.md");
pub const BASE_ENGINEER: &str = include_str!("assets/agents/BASE-ENGINEER.md");
pub const BASE_OPS: &str = include_str!("assets/agents/BASE-OPS.md");
pub const BASE_QA: &str = include_str!("assets/agents/BASE-QA.md");
pub const BASE_RESEARCH: &str = include_str!("assets/agents/BASE-RESEARCH.md");
pub const API_QA: &str = include_str!("assets/agents/api-qa.md");
pub const CODE_ANALYZER: &str = include_str!("assets/agents/code-analyzer.md");
pub const CODE_CRITIC: &str = include_str!("assets/agents/code-critic.md");
pub const DART_ENGINEER: &str = include_str!("assets/agents/dart-engineer.md");
pub const DATA_ENGINEER: &str = include_str!("assets/agents/data-engineer.md");
pub const DOCUMENTATION: &str = include_str!("assets/agents/documentation.md");
pub const DOTNET_ENGINEER: &str = include_str!("assets/agents/dotnet-engineer.md");
pub const ELIXIR_ENGINEER: &str = include_str!("assets/agents/elixir-engineer.md");
pub const ENGINEER: &str = include_str!("assets/agents/engineer.md");
pub const GCP_OPS: &str = include_str!("assets/agents/gcp-ops.md");
pub const GOLANG_ENGINEER: &str = include_str!("assets/agents/golang-engineer.md");
pub const JAVA_ENGINEER: &str = include_str!("assets/agents/java-engineer.md");
pub const JAVASCRIPT_ENGINEER: &str = include_str!("assets/agents/javascript-engineer.md");
pub const LOCAL_OPS: &str = include_str!("assets/agents/local-ops.md");
pub const MEMORY_MANAGER: &str = include_str!("assets/agents/memory-manager.md");
pub const MPM_AGENT_MANAGER: &str = include_str!("assets/agents/mpm-agent-manager.md");
pub const MPM_SKILLS_MANAGER: &str = include_str!("assets/agents/mpm-skills-manager.md");
pub const NEXTJS_ENGINEER: &str = include_str!("assets/agents/nextjs-engineer.md");
pub const PHOENIX_ENGINEER: &str = include_str!("assets/agents/phoenix-engineer.md");
pub const PHP_ENGINEER: &str = include_str!("assets/agents/php-engineer.md");
pub const PROMPT_ENGINEER: &str = include_str!("assets/agents/prompt-engineer.md");
pub const PYTHON_ENGINEER: &str = include_str!("assets/agents/python-engineer.md");
pub const QA: &str = include_str!("assets/agents/qa.md");
pub const REACT_ENGINEER: &str = include_str!("assets/agents/react-engineer.md");
pub const REFACTORING_ENGINEER: &str = include_str!("assets/agents/refactoring-engineer.md");
pub const RESEARCH: &str = include_str!("assets/agents/research.md");
pub const RUBY_ENGINEER: &str = include_str!("assets/agents/ruby-engineer.md");
pub const RUST_ENGINEER: &str = include_str!("assets/agents/rust-engineer.md");
pub const SECRETS_MANAGER: &str = include_str!("assets/agents/secrets-manager.md");
pub const SECURITY: &str = include_str!("assets/agents/security.md");
pub const SVELTE_ENGINEER: &str = include_str!("assets/agents/svelte-engineer.md");
pub const TAURI_ENGINEER: &str = include_str!("assets/agents/tauri-engineer.md");
pub const TICKETING: &str = include_str!("assets/agents/ticketing.md");
pub const TYPESCRIPT_ENGINEER: &str = include_str!("assets/agents/typescript-engineer.md");
pub const VERCEL_OPS: &str = include_str!("assets/agents/vercel-ops.md");
pub const VERSION_CONTROL: &str = include_str!("assets/agents/version-control.md");
pub const WEB_QA: &str = include_str!("assets/agents/web-qa.md");
pub const WEB_UI_ENGINEER: &str = include_str!("assets/agents/web-ui-engineer.md");
pub const AGENT_ASSETS: &[(&str, &str)] = &[
("BASE-AGENT.md", BASE_AGENT),
("BASE-ENGINEER.md", BASE_ENGINEER),
("BASE-OPS.md", BASE_OPS),
("BASE-QA.md", BASE_QA),
("BASE-RESEARCH.md", BASE_RESEARCH),
("api-qa.md", API_QA),
("code-analyzer.md", CODE_ANALYZER),
("code-critic.md", CODE_CRITIC),
("dart-engineer.md", DART_ENGINEER),
("data-engineer.md", DATA_ENGINEER),
("documentation.md", DOCUMENTATION),
("dotnet-engineer.md", DOTNET_ENGINEER),
("elixir-engineer.md", ELIXIR_ENGINEER),
("engineer.md", ENGINEER),
("gcp-ops.md", GCP_OPS),
("golang-engineer.md", GOLANG_ENGINEER),
("java-engineer.md", JAVA_ENGINEER),
("javascript-engineer.md", JAVASCRIPT_ENGINEER),
("local-ops.md", LOCAL_OPS),
("memory-manager.md", MEMORY_MANAGER),
("mpm-agent-manager.md", MPM_AGENT_MANAGER),
("mpm-skills-manager.md", MPM_SKILLS_MANAGER),
("nextjs-engineer.md", NEXTJS_ENGINEER),
("phoenix-engineer.md", PHOENIX_ENGINEER),
("php-engineer.md", PHP_ENGINEER),
("prompt-engineer.md", PROMPT_ENGINEER),
("python-engineer.md", PYTHON_ENGINEER),
("qa.md", QA),
("react-engineer.md", REACT_ENGINEER),
("refactoring-engineer.md", REFACTORING_ENGINEER),
("research.md", RESEARCH),
("ruby-engineer.md", RUBY_ENGINEER),
("rust-engineer.md", RUST_ENGINEER),
("secrets-manager.md", SECRETS_MANAGER),
("security.md", SECURITY),
("svelte-engineer.md", SVELTE_ENGINEER),
("tauri-engineer.md", TAURI_ENGINEER),
("ticketing.md", TICKETING),
("typescript-engineer.md", TYPESCRIPT_ENGINEER),
("vercel-ops.md", VERCEL_OPS),
("version-control.md", VERSION_CONTROL),
("web-qa.md", WEB_QA),
("web-ui-engineer.md", WEB_UI_ENGINEER),
];
pub const AGENT_ASSETS_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/src/assets/agents");
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_asset_is_non_empty() {
for (name, body) in AGENT_ASSETS {
assert!(
!body.trim().is_empty(),
"agent asset `{name}` embedded empty"
);
}
}
#[test]
fn table_filenames_are_unique() {
let mut seen: Vec<&str> = AGENT_ASSETS.iter().map(|(n, _)| *n).collect();
let total = seen.len();
seen.sort_unstable();
seen.dedup();
assert_eq!(total, seen.len(), "duplicate filename in AGENT_ASSETS");
assert_eq!(total, 43, "AGENT_ASSETS must carry all 43 agent assets");
}
#[test]
fn every_entry_embeds_the_file_it_names() {
for (name, body) in AGENT_ASSETS {
let path = std::path::Path::new(AGENT_ASSETS_DIR).join(name);
let on_disk = std::fs::read_to_string(&path)
.unwrap_or_else(|e| panic!("read {}: {e}", path.display()));
assert_eq!(
on_disk, *body,
"`{name}`'s table entry does not embed {name} — check the \
const wired to that filename"
);
}
}
#[test]
fn no_two_entries_share_content() {
for (i, (name_a, body_a)) in AGENT_ASSETS.iter().enumerate() {
for (name_b, body_b) in AGENT_ASSETS.iter().skip(i + 1) {
assert!(
!std::ptr::eq(*body_a, *body_b),
"`{name_a}` and `{name_b}` embed the same string"
);
}
}
}
#[test]
fn table_matches_the_directory() {
let mut on_disk: Vec<String> = std::fs::read_dir(AGENT_ASSETS_DIR)
.expect("the embedded agent roster directory must exist")
.flatten()
.map(|e| e.file_name().to_string_lossy().into_owned())
.filter(|n| n.ends_with(".md"))
.collect();
on_disk.sort();
let mut in_table: Vec<String> =
AGENT_ASSETS.iter().map(|(n, _)| (*n).to_string()).collect();
in_table.sort();
assert_eq!(
on_disk, in_table,
"AGENT_ASSETS and {AGENT_ASSETS_DIR} disagree — a roster file was \
added or removed without updating the table, so it would ship \
embedded by nobody (or be embedded while missing from disk)"
);
}
#[test]
fn credential_switching_is_forbidden_in_the_shipped_assets() {
for (name, body) in [
("BASE-AGENT.md", BASE_AGENT),
("version-control.md", VERSION_CONTROL),
] {
let flat = body.replace('\n', " ");
assert!(
flat.contains("Never switch") && flat.contains("credential"),
"`{name}` must forbid switching to another `gh` \
account/token/credential to obtain a missing permission (#5680)"
);
}
assert!(
VERSION_CONTROL.contains("When the PM relays operator authorization to merge directly"),
"the credential-switching ban must leave the PM-relayed \
admin-merge authorization intact (#2842)"
);
}
#[test]
fn ticketing_and_version_control_are_not_haiku() {
for (name, body) in [
("ticketing.md", TICKETING),
("version-control.md", VERSION_CONTROL),
] {
let frontmatter = body
.strip_prefix("---\n")
.and_then(|rest| rest.split_once("\n---"))
.map(|(fm, _)| fm)
.unwrap_or_else(|| panic!("`{name}` must open with YAML frontmatter"));
assert!(
!frontmatter.lines().any(|l| l.trim() == "model: haiku"),
"`{name}` frontmatter must not declare `model: haiku` (#7274); \
got:\n{frontmatter}"
);
assert!(
frontmatter.lines().any(|l| l.trim() == "model: sonnet"),
"`{name}` frontmatter must declare `model: sonnet` (#7274); \
got:\n{frontmatter}"
);
}
}
#[test]
fn worktree_removal_is_the_pms_in_the_shipped_base_agent() {
let flat = BASE_AGENT.replace('\n', " ");
assert!(
flat.contains("Never remove a worktree") && flat.contains("#5791"),
"`BASE-AGENT.md` must forbid an agent removing a worktree (#5791)"
);
assert!(
flat.contains("the PM removes the task-owned path")
&& flat.contains("git worktree remove /absolute/repo/.claude/worktrees/task-name")
&& flat.contains("ownership, clean state, merged status and no other live"),
"`BASE-AGENT.md` must name the PM's replacement command, not just \
refuse (#5791)"
);
}
#[test]
fn self_analysis_reporting_ships_in_the_base_agent() {
let flat = BASE_AGENT.replace('\n', " ");
for (fact, needle) in [
(
"the resident section exists",
"## Self-Improvement Reporting",
),
(
"the trigger names the point in the run",
"before your final report",
),
(
"the skill file is named",
"{{TM_SKILLS}}/self-improvement-loop/SKILL.md",
),
(
"the memory tag survives as a resident fact",
"`self-improvement-hypothesis`",
),
("a subagent never files directly", "No Subagent Fan-Out"),
] {
assert!(
flat.contains(needle),
"`BASE-AGENT.md` must state that {fact} (#6935, #6937, #7723)"
);
}
assert!(
!flat.contains("Skill(skill=\"self-improvement-loop\")"),
"BASE-AGENT must name `self-improvement-loop` in prose, not a \
modelled `Skill(...)` call — most agents' `tools:` omit `Skill` \
(#7683, #7723)"
);
}
#[test]
fn wait_exit_codes_and_improvement_block_headings_are_resident() {
let flat = BASE_AGENT.replace('\n', " ");
for (fact, needle) in [
("exit 0 (met) is documented", "`0`"),
("exit 75 (pending) is documented", "`75`"),
("exit 1 (timeout) is documented", "`1`"),
("exit 2 (error) is documented", "`2`"),
("the command to re-issue on exit 75 is named", "`rerun=`"),
(
"the Improvement recommendations heading is named",
"Improvement recommendations",
),
("its Symptom field is named", "Symptom"),
("its Cause field is named", "Cause"),
("its Evidence field is named", "Evidence"),
("the Prompt feedback heading is named", "Prompt feedback"),
(
"the fast-loop memory tag is named",
"self-improvement-hypothesis",
),
] {
assert!(
flat.contains(needle),
"`BASE-AGENT.md` must state that {fact} (#7723 fix round)"
);
}
assert!(
flat.to_lowercase().contains("verbatim"),
"`BASE-AGENT.md` must require the `rerun=` command to be re-issued \
verbatim (#7723 fix round)"
);
}
#[test]
fn engineer_assets_name_no_repo_specific_doc_gate_script() {
const REPO_SPECIFIC_GATES: [&str; 3] = [
"check_test_pointers.sh",
"check_line_cap.sh",
"check_changelog_fragment.sh",
];
for (name, body) in [
("BASE-AGENT.md", BASE_AGENT),
("BASE-ENGINEER.md", BASE_ENGINEER),
("rust-engineer.md", RUST_ENGINEER),
] {
for gate in REPO_SPECIFIC_GATES {
assert!(
!body.contains(gate),
"`{name}` names `{gate}`, a script that exists in \
trusty-tools and not in every project (#7247) — tell the \
agent to read the project's own CLAUDE.md and `scripts/` \
instead of naming a filename"
);
}
}
}
#[test]
fn general_purpose_assets_state_no_repo_specific_literal() {
const REPO_SPECIFIC_LITERALS: [&str; 12] = [
"trusty-common",
"test_trusty_common_lanes.sh",
"check_sld.sh",
"check_line_cap.sh",
"check_test_pointers.sh",
"check_changelog_fragment.sh",
"check-pr-version-bump.sh",
"required-checks.sh",
"is-branch-caused.sh",
"memory-core",
"bobmatnyc/trusty-tools",
"crates/",
];
const FRAMEWORK_SCOPED: [&str; 4] = [
"mpm-agent-manager.md",
"mpm-skills-manager.md",
"ticketing.md",
"version-control.md",
];
for (name, body) in AGENT_ASSETS {
if FRAMEWORK_SCOPED.contains(name) {
continue;
}
for literal in REPO_SPECIFIC_LITERALS {
if *name == "BASE-AGENT.md" && literal == "bobmatnyc/trusty-tools" {
continue;
}
assert!(
!body.contains(literal),
"`{name}` states `{literal}`, which exists in trusty-tools \
and not in every project (#7270) — these assets deploy \
unchanged everywhere, so point the agent at the project's \
own CLAUDE.md and `scripts/` instead of naming a literal"
);
}
}
}
#[test]
fn base_templates_travel_with_the_roster() {
for base in [
"BASE-AGENT.md",
"BASE-ENGINEER.md",
"BASE-OPS.md",
"BASE-QA.md",
"BASE-RESEARCH.md",
] {
assert!(
AGENT_ASSETS.iter().any(|(n, _)| *n == base),
"`{base}` must ship alongside the agents that extend it"
);
}
}
#[test]
fn regression_proof_reverts_against_the_pre_fix_commit() {
assert!(
BASE_ENGINEER.contains("git merge-base origin/main HEAD"),
"BASE-ENGINEER must name the pre-fix commit the revert targets (#7705)"
);
assert!(
BASE_ENGINEER.contains("never to a bare"),
"BASE-ENGINEER must forbid reverting to a bare `origin/main` (#7705)"
);
assert!(
!BASE_ENGINEER.contains("`git checkout origin/main -- <paths>`"),
"the moving-ref revert recipe must be gone, not merely warned about (#7705)"
);
assert!(
BASE_ENGINEER.contains("`./scripts/<name>.sh`"),
"BASE-ENGINEER must state the executable gate-script spelling (#7705)"
);
}
}