AIchain Skill: A Prompt as a Reusable Object The AIchain library introduces "Skill," a Python object that treats prompts as reusable, parameterizable components rather than hard-coded strings. By separating prompt templates from runtime data and model execution, Skill allows developers to version-control, test, and swap underlying AI models without altering business logic. The approach mirrors parameterized SQL queries, enabling prompt engineers to review and modify prompts independently of application code. 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 https://github.com/yaitio/aichain and its serialization dependency: pip install yait-aichain pyyaml Here's the simplest Skill — a one-sentence explainer with a {topic} variable: python 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: python 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. python 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: 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. 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. 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.