---
type: concept
title: "Dynamic System Prompt"
description: "Assembling an agent's system prompt at runtime by scanning a skills/context directory and injecting each file's front-matter description and path onto the static base instructions, which is what makes skills portable to any framework."
tags: [skills, pydantic-ai, context-engineering]
videos: [claude-skills-arent-just-for-claude-heres-how-to-build-them-for-any-agent]
created: 2026-07-21
updated: 2026-07-21
---

# Dynamic System Prompt

A dynamic system prompt is one that is built at request time rather than hard-coded: a static base of instructions plus a block generated by scanning a directory on disk. Cole describes the assembly directly: "we're going to be taking advantage of what is called a dynamic system prompt. We have our static content... But then also, we're going to collect the descriptions from all YAML front matters, all of our skill.mds, and we're going to put that in our system prompt." [0:06:45] The injected block is deliberately thin - each skill contributes only its name, one-line description, and file path, not its body.

## Why it matters

This is the mechanism that demystifies [Skills](./skills.md) and makes them portable. A skill is not a proprietary feature of one coding agent; it is a markdown file plus a loader that advertises its existence in the prompt and lets the agent read the full file when it becomes relevant. Once you can write that loader yourself, skills stop being vendor-locked and become a pattern any agent framework can adopt, which is a concrete piece of [Provider Independence](./provider-independence.md).

It is also [Progressive Disclosure](./progressive-disclosure.md) implemented in the cheapest possible way. Ten skills cost ten lines of system prompt instead of ten full documents, so the agent knows everything it *could* do while paying context for almost none of it. Because the scan happens per run, dropping a new markdown file into the directory changes the agent's capabilities with no code deploy - the filesystem is the registry.

## How it works

In a framework, the system prompt becomes a function rather than a string. "in pineanti the way that you do this is you reference your agent dotsystem prompt. This is our Python decorator. Now the function below this is where we get to define the system prompt for our agent." [0:14:22] Inside that function you glob the skills directory, parse each file's YAML front matter for `name` and `description`, and append the resulting list, each entry paired with the path the agent can read when it decides the skill applies. The base instructions tell it exactly that: consult the list, then open the file.

## Prerequisites

- [System Prompt Engineering](./system-prompt-engineering.md) - the static base this extends.
- [Skills](./skills.md) - the markdown units being advertised.

## Part of

- [Context Engineering](./context-engineering.md) - a runtime strategy for deciding what occupies the window.
- [File-System-Based Agents](./file-system-based-agents.md) - capability lives in files on disk, discovered by scanning.

## Contrasts with

- [Tool Design](./tool-design.md) - tools are registered in code and always present in the schema; skills are files listed by description and loaded only on demand.
- [Global Rules](./global-rules.md) - always-on instructions that never vary between runs.

## Related

- [Progressive Disclosure](./progressive-disclosure.md) - the principle this implements at the prompt layer.
- [Provider Independence](./provider-independence.md) - the payoff of owning the loader.
- [Agent Prompting Techniques](./agent-prompting.md) and [Prompt Templating](./prompt-templating.md) - the broader craft of prompt assembly.
- [SDK vs. Framework Decision](./sdk-vs-framework-decision.md) - whichever you pick, the hook for a dynamic prompt exists.

## Tools

- [Pydantic AI](../entities/tools/pydantic-ai.md) - the `@agent.system_prompt` decorator turns the system prompt into a function evaluated per run.
- [Claude Code](../entities/tools/claude-code.md) - the reference implementation of skills that this pattern reproduces elsewhere.
- [Python](../entities/tools/python.md) - where the directory scan and front-matter parsing live.

## Sources

- [Claude Skills Aren't Just for Claude - Here's How to Build Them for ANY Agent](../sources/claude-skills-arent-just-for-claude-heres-how-to-build-them-for-any-agent.md) - "[0:06:45] we're going to be taking advantage of what is called a dynamic system prompt. We have our static content... But then also, we're going to collect the descriptions from all YAML front matters, all of our skill.mds, and we're going to put that in our system prompt."
- [Claude Skills Aren't Just for Claude - Here's How to Build Them for ANY Agent](../sources/claude-skills-arent-just-for-claude-heres-how-to-build-them-for-any-agent.md) - "[0:14:22] in pineanti the way that you do this is you reference your agent dotsystem prompt. This is our Python decorator. Now the function below this is where we get to define the system prompt for our agent."
