The MentisDB Agent Memory Cookbook

Patterns and recipes for building AI agents that remember

2.3 Dynamic Skill Loading

Skills are versioned operating instructions for agents. A skill is not a prompt pasted into one chat; it is an immutable artifact in the registry. Agents discover skills during bootstrap, read the ones they trust, and then apply them consistently across sessions.

The pattern

fn dynamic_skill_loading() -> io::Result<()> {
    let dir = tempfile::tempdir()?;
    let mut registry = mentisdb::SkillRegistry::open(dir.path())?;

    let v1 = r#"---
tags: [rust, review]
triggers: [review]
---
# Code Review

Check correctness before style. Report findings first.
"#;

    let summary = registry.upload_skill(
        mentisdb::SkillUpload::new("review-agent", mentisdb::SkillFormat::Markdown, v1)
            .with_skill_id("code-review"),
    )?;
    assert_eq!(summary.skill_id, "code-review");
    assert_eq!(summary.version_count, 1);

    let output = registry.read_skill(
        "code-review",
        None,
        mentisdb::SkillFormat::Markdown,
    )?;
    assert!(output.content.contains("Code Review"));
    assert!(output.warnings.is_empty());

    let matches = registry.search_skills(&mentisdb::SkillQuery {
        text: Some("correctness".into()),
        limit: Some(1),
        ..Default::default()
    });
    assert_eq!(matches.len(), 1);
    assert_eq!(matches[0].skill_id, "code-review");

    let v2 = r#"---
tags: [rust, review]
triggers: [review]
---
# Code Review

Check correctness and safety before style. Report findings first.
"#;
    let updated = registry.upload_skill(
        mentisdb::SkillUpload::new("review-agent", mentisdb::SkillFormat::Markdown, v2)
            .with_skill_id("code-review"),
    )?;
    assert_eq!(updated.version_count, 2);
    assert_eq!(registry.skill_versions("code-review")?.len(), 2);
    Ok(())
}
Operational rule: dynamic does not mean unaudited. Trust decisions happen before reading unknown skill content into an agent's context.

When to use it

Use dynamic skills for reusable procedures: release engineering, crash triage, code review, security checks, and project-specific conventions. Store volatile task state as thoughts; store reusable behavior as skills.