Skills and Personas
Compose Namzu system prompts from personas, skill files, and session context using the public @namzu/sdk prompt surfaces.
Prompt composition in @namzu/sdk is intentionally split into reusable parts instead of one giant string. Personas capture stable behavioral shape. Skills capture reusable instructions from disk. Session context injects run-specific detail late.
1. The Prompt Layers
The public prompt-building surfaces map to three different responsibilities:
| Surface | Owns | Main exports |
|---|---|---|
| Persona | identity, expertise, constraints, output style | mergePersonas, withSessionContext, persona types |
| Skill | reusable instruction files with frontmatter | SkillRegistry, discoverSkills, loadSkill, resolveSkillChain |
| Prompt assembly | final system prompt text | assembleSystemPrompt |
This separation matters because the runtime treats stable and dynamic prompt parts differently.
2. Build a Persona in Code
This example is fully local and does not depend on a provider package:
3. Skills Are Loaded from SKILL.md
The skill loader expects each skill to live in its own directory with a SKILL.md file and YAML frontmatter.
Key loader rules from the public implementation:
- the file must start with frontmatter
nameanddescriptionare required- the
namemust match the directory name - names must be lowercase kebab-case
To load a directory of skills:
Why the disclosure level matters:
| Level | What you get |
|---|---|
metadata | only name and description |
full | metadata plus SKILL.md body |
assets | currently also loads the body; use when your host additionally resolves skill assets |
If a skill body is missing, it cannot contribute instruction text to the assembled prompt.
4. Running a Persona Plus Skills Through an Agent
This example stays offline-friendly by using MockLLMProvider, but it exercises the real prompt surfaces:
5. Skill Inheritance and Resolution
Use resolveSkillChain() when skills come from two levels, such as category defaults plus agent-local overrides:
Resolution rule:
- inherited skills are loaded first
- agent-local skills are loaded second
- later skills with the same name replace earlier ones in the resolved set
6. One Very Important Runtime Detail
From the current prompt builder implementation:
- if
systemPromptis present, the runtime uses it directly - if
systemPromptis absent andpersonais present, the runtime callsassembleSystemPrompt(persona, skills)
That means systemPrompt wins over persona-driven prompt composition. Use one consciously; do not expect both to merge automatically.
7. Session Context Is Dynamic on Purpose
withSessionContext() does not just append more static prose. In the lower-level prompt builder, session context is split into the dynamic prompt segment so it can vary run to run without forcing the rest of the persona to change.
Use session context for:
- current repo or workspace information
- current task framing
- short-lived run metadata that should influence output
Do not use it for durable behavior rules. Durable rules belong in the base persona or skill body.
8. Common Mistakes
| Mistake | Why it hurts |
|---|---|
loading skills at metadata level and expecting them to affect the prompt | metadata-only skills do not carry instruction bodies |
passing both systemPrompt and persona and expecting an automatic merge | the runtime prefers systemPrompt directly |
| putting per-run context into the base persona | it makes stable behavior harder to reuse |
| treating skills as opaque strings with no frontmatter rules | the loader validates SKILL.md shape and naming |
| using skills for hidden runtime state | keep private runtime data in InvocationState, not prompt text |