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.
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.
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.
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.
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"
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)
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:
skill.save()
serializes the model name, prompt template, and configuration β but intentionally strips the API key. You pass it from the environment when you call Skill.load()
. No secrets in your repo.validator_skill.yaml
, tweak the prompt wording, and commit it β without touching Python.prompts/
directory, tag it v1.2
, run automated tests against it in CI. If new wording degrades output quality, git revert
and you're done.When a prompt becomes an object, workflows that strings simply can't support become straightforward:
prompts/
directory. Git tracks every change, who made it, and when β just as it tracks schema migrations.
Skill(model: Model, input: dict)
skill.run(variables: dict = {}) -> str
skill.save(path: str) -> None
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.
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.