A prompt buried in an f-string is technical debt. You can't test it. You can't save it to a file. You can't hand it to a colleague and say "here's the extraction logic." The moment you hard-code a prompt into a string, you've welded your application logic to a single, frozen instruction — one that will rot as models improve and requirements shift.
Skill fixes that. It turns a prompt into a first-class object: something you can construct, parameterize, persist, reload, version-control, and swap models underneath — all without changing a single line of business logic.
The Problem with Naked Strings
Consider the typical approach:
response = client.chat(f"What is {topic} in one sentence?")
This line mixes three concerns: the prompt template, the runtime data, and the model that executes it. Change any one of those, and you're editing the same line. Want to test the prompt with different inputs? You rewrite the call. Want to try a cheaper model? You rewire the client. Want a non-developer on your team to review the prompt? You point them at application code.
SQL solved this exact problem decades ago. Write a parameterized query once, bind values at execution time, and the database engine is a separate concern entirely. Skill applies the same separation to prompts.
Skill in Practice
Install the library and its serialization dependency:
pip install yait-aichain pyyaml
Here's the simplest Skill — a one-sentence explainer with a {topic} variable:
import os
from yait_aichain.models import Model
from yait_aichain.skills import Skill
skill = Skill(
model=Model("claude-sonnet-4-6", api_key=os.getenv("ANTHROPIC_API_KEY")),
input={
"messages": [{
"role": "user",
"parts": ["What is {topic} in one sentence?"],
}]
},
)
result = skill.run(variables={"topic": "machine learning"})
print(result)
Two things to notice. First, {topic} is a placeholder inside the prompt template — not an f-string resolved at definition time. The value gets substituted only when you call .run(variables={...}). Second, the model is declared at construction, not at call time. The Skill knows which model it targets.
That separation matters. The same Skill instance can run with {"topic": "quantum computing"}, then {"topic": "gradient descent"}, without rebuilding anything. The template stays fixed; the data varies. Exactly like a prepared statement.
One Prompt, Three Models
The key differentiator of a Skill: it's built around the model most effective for a specific task — balancing quality, speed, and cost. What one model handled well six months ago, another can do dramatically better today. Skill lets you act on that without rewriting your logic.
Here's what that looks like in code:
import os
from yait_aichain.models import Model
from yait_aichain.skills import Skill
PROMPT = {
"messages": [{
"role": "user",
"parts": ["What is {topic} in one sentence?"],
}]
}
models = [
Model("claude-sonnet-4-6", api_key=os.getenv("ANTHROPIC_API_KEY")),
Model("gpt-4o-mini", api_key=os.getenv("OPENAI_API_KEY")),
Model("gemini-2.5-flash", api_key=os.getenv("GOOGLE_AI_API_KEY")),
]
for model in models:
skill = Skill(model=model, input=PROMPT)
result = skill.run(variables={"topic": "machine learning"})
print(f"[{model.name}]\n{result}\n")
The prompt template is defined once. The loop swaps only the Model. You get three answers from three providers — Anthropic, OpenAI, Google — with zero changes to the prompt logic. (model.name is a string attribute on Model that returns the identifier you passed at construction, used here purely for labeling output.) When a newer model returns a better answer at a fraction of the cost, you change one string and move on.
Save, Version, Share
The moment a prompt lives in a Python file, it's coupled to that file's deployment cycle. Edit the prompt, redeploy the app. That's fine until you want a prompt engineer — or your future self at 11pm — to iterate on prompts independently.
Skill supports serialization to YAML. Same idea as versioning a migration script: track every change in Git, roll back when new wording degrades output quality.
import os
from yait_aichain.models import Model
from yait_aichain.skills import Skill
YAML_PATH = "validator_skill.yaml"
# Build and save
skill = Skill(
model=Model("claude-sonnet-4-6", api_key=os.getenv("ANTHROPIC_API_KEY")),
input={
"messages": [{
"role": "user",
"parts": ["Review the following text and return only corrected version: {text}"],
}]
},
)
skill.save(YAML_PATH)
# Later — reload and run
loaded_skill = Skill.load(YAML_PATH, api_key=os.getenv("ANTHROPIC_API_KEY"))
result = loaded_skill.run(variables={"text": "The quick brown fox jump over the lazy dog."})
print(result)
A few details worth highlighting:
-
API keys never hit disk.
skill.save()serializes the model name, prompt template, and configuration — but intentionally strips the API key. You pass it from the environment when you callSkill.load(). No secrets in your repo. -
YAML is human-readable. A teammate can open
validator_skill.yaml, tweak the prompt wording, and commit it — without touching Python. -
The file is an artifact. Store it in a
prompts/directory, tag itv1.2, run automated tests against it in CI. If new wording degrades output quality,git revertand you're done.
Why Objects Beat Strings
When a prompt becomes an object, workflows that strings simply can't support become straightforward:
- Testing. Write a unit test that loads a Skill, runs it against five known inputs, and asserts output structure. Run that test on every PR.
-
Versioning. Store Skills as YAML files in a
prompts/directory. Git tracks every change, who made it, and when — just as it tracks schema migrations. - Model migration. When a newer, faster, or cheaper model appears, update the model name in the YAML file. The prompt template and your application code stay untouched.
- Collaboration. A domain expert writes the prompt. A developer writes the pipeline. Neither blocks the other.
- Independent deployment. Ship new prompt versions without redeploying application code. Load the latest YAML from a shared path or artifact store.
The API at a Glance
# Construct
Skill(model: Model, input: dict)
# Run with variable substitution
skill.run(variables: dict = {}) -> str
# Persist
skill.save(path: str) -> None
# Restore (api_key is a keyword argument)
Skill.load(path: str, *, api_key: str) -> Skill
Four operations. That's the entire surface area. A Skill does exactly one thing — execute a parameterized prompt against a specific model — and exposes exactly the controls you need to manage it over time.
From String to Strategy
The shift from f-string to Skill is small in code and large in practice. You go from a prompt that's invisible, untestable, and welded to one model — to one that's named, versioned, portable, and model-aware.
Next in this series: Chain — what happens when one Skill's output feeds into another. But it all starts here, with one prompt treated as a real artifact, not a throwaway string.
Top comments (0)