From 506cae09ff6ebafa1ce347dd2f8d2a15b3d52b9a Mon Sep 17 00:00:00 2001 From: eddiesoehnel Date: Tue, 14 Jul 2026 14:10:19 -0600 Subject: [PATCH] added --- prompt-skill-template/CHANGELOG.md | 4 - prompt-skill-template/OSDR-framework.md | 161 --- prompt-skill-template/README.md | 419 ------ .../advanced-ai-agent-design-framework.md | 939 ------------- prompt-skill-template/personas.md | 19 - .../ratchet-based-skill-framework.md | 1225 ----------------- 6 files changed, 2767 deletions(-) delete mode 100644 prompt-skill-template/CHANGELOG.md delete mode 100644 prompt-skill-template/OSDR-framework.md delete mode 100644 prompt-skill-template/README.md delete mode 100644 prompt-skill-template/advanced-ai-agent-design-framework.md delete mode 100644 prompt-skill-template/personas.md delete mode 100644 prompt-skill-template/ratchet-based-skill-framework.md diff --git a/prompt-skill-template/CHANGELOG.md b/prompt-skill-template/CHANGELOG.md deleted file mode 100644 index b1d1a14..0000000 --- a/prompt-skill-template/CHANGELOG.md +++ /dev/null @@ -1,4 +0,0 @@ -6/26/26: added sections on Modularity and Skill Packs As Communication Rail to `READEME.md`. -6/24/26: added `Advanced AI Agent Design Framework` and referenced in where needed in `README.md`. -6/21/26: added `OSDR` framework doc -6/16/26: improved the receipt sections so that a durable, first class artifact is left so any future agent/process will know exactly what was run and how to accomplish the task. Pulled from https://x.com/ishaansehgal/status/2065129901427130678 \ No newline at end of file diff --git a/prompt-skill-template/OSDR-framework.md b/prompt-skill-template/OSDR-framework.md deleted file mode 100644 index e7a0d09..0000000 --- a/prompt-skill-template/OSDR-framework.md +++ /dev/null @@ -1,161 +0,0 @@ -# Outcome–Skill–Data–Receipt (OSDR) Framework - -A practical framework for designing AI agents, prompts, and workflows. - -## Core Principle - -Most AI systems focus on the model. The real long-term value lives in the layers around the model: - -```text -Outcome - ↓ -Skill - ↓ -Data - ↓ -Execution - ↓ -Receipt -``` - -Over time, models become commodities. Skills, data, and receipts become the proprietary intelligence layer. - ---- - -## 1. Outcome - -**What final state must exist for the task to be considered complete?** - -The outcome defines success. It is the destination, not the steps along the way. - -### Example - ---- - -## 2. Skill - -**How should the work be performed?** - -A skill is more than a prompt. It contains: - -* Methodology -* Domain expertise -* Checklists -* Tools required -* Decision criteria -* Validation rules -* Output structure - -Skills are reusable intellectual property. - -### Example - ---- - -## 3. Data - -**What information and context should be used?** - -Data provides the raw material for reasoning. - -Examples: - -* Documents -* Databases -* APIs -* Websites -* Knowledge graphs -* Personal Identity Documents (PIDs) -* Historical receipts - -### Example - ---- - -## 4. Receipt - -**What happened during execution?** - -A receipt captures: - -* Inputs used -* Decisions made -* Outputs generated -* Validation results -* Errors encountered -* Recommendations -* Timestamp - -Receipts transform one-time execution into organizational memory. - -### Example - ---- - -## Optional Evaluation Layer - -To improve quality and completeness, define explicit success criteria. - -### Example - -```text -Evaluation: -- Minimum 15 sources -- Sources less than 7 days old -- Actionable insights section present -- No duplicate links -``` - -If evaluation fails, continue execution until the outcome is achieved. - ---- - -## Optional Loop Layer - -Defines when the process should run. - -### Example - -```text -Schedule: -Every Monday at 9:00 AM Mountain Time -``` - ---- - -# Complete Prompt Structure - -```text -OUTCOME -What final state must exist? -Some are using goals,but goals are really just signpost along the way to the outcome. A goal could be an interim task sequence using this framework that get us to the outcome. - -SKILL -What methodology or skill should be used? - -DATA -What information sources should be used? - -EVALUATION -How do we verify success? - -RECEIPT -What execution details should be recorded? - -LOOP (Optional) -When should this run? -``` - ---- - -# Key Insight - -**Outcome defines where we are going.** - -**Skill defines how we think.** - -**Data defines what we know.** - -**Receipt defines what we learned.** - -Together, these create a system that not only produces answers, but continuously builds reusable organizational intelligence over time. A company, community, or individual becomes smarter over time not because the model improves, but because the accumulated receipts continuously refine the skills and provide context for future decisions. diff --git a/prompt-skill-template/README.md b/prompt-skill-template/README.md deleted file mode 100644 index d4bb5b9..0000000 --- a/prompt-skill-template/README.md +++ /dev/null @@ -1,419 +0,0 @@ -# Prompt Skill Template - -This repo is a practical starting point for turning any repeatable task or workflow or AI prompts into reusable, testable skills. I assembled and maintain it from people in the AI industry who are open sourcing their work. - -The central belief behind this repo is that skills are the durable layer of AI work. Models will change, tools will change, and different systems will call the work by different names, but a well-written skill can move across them. The skill defines how the work should be done, and the receipts or logs from each run preserve what happened, what was produced, and what was learned. In that sense, the valuable asset is not just the AI model. It is the skill pack and the history of outputs it creates. - -If you want to automate skills, you use a harness. A harness is the system that calls the AI, runs skills in sequence, schedules recurring work, or launches multiple agents in parallel. The harness can call different models or tools, but the skill documents remain the center of the workflow. They are the part you own, improve, and carry forward. - -If you have ever written a prompt that worked once but was hard to repeat later, this repo is meant to help. The core idea is simple: a useful AI workflow should not live only in a chat transcript. It should become a skill with a clear outcome, required inputs, validation steps, and a receipt of what happened. - -# Security Scan NOW! - -Regardless if you trust where a skill pack like this repo comes from, always ask your local AI model (Codex Dekstop, Claude Desktop, or any other model you use) to scan this repo for any vulnerabilities before you start working with it. - -## What This Helps You Do - -Use this repo when you want to: - -- write better prompts for repeatable work -- turn a one-off AI workflow into a reusable process -- make AI agents less likely to skip important steps -- define what "done" means before the AI starts working -- create receipts so future AI runs can understand what happened before -- improve a workflow every time it fails instead of relying on memory -- coordinate multiple AI roles, such as reviewer, designer, domain expert, or code expert -- create triggers when to run the skill and ensure it operates around edge cases - -The documents here are not about prompt tricks. They are about making AI work more dependable. - -## Who This Is For - -This repo can help: - -- people who use ChatGPT, Claude, Codex, or other AI tools for real work -- teams who want AI outputs to be more consistent -- builders creating repeatable agent workflows -- non-technical users who want clearer instructions for AI tools -- technical users who want to treat prompts and skills more like software - -You do not need to be an AI expert to use this. Start with the OSDR framework, then use the ratchet framework when you are ready to make a workflow more durable. - -## The Main Idea - -A strong AI workflow should answer these questions: - -- What outcome should exist when the work is complete? -- What skill or method should the AI use? -- What data should it rely on? -- How will the result be checked? -- What receipt should be left behind so the work can be reviewed or repeated? -- What should be improved after a failure? - -This repo gives language and structure for answering those questions. - -## From Prompt To Autonomous Agent - -This repo is meant to scale with your AI maturity. - -At the beginning, you use it to write clearer prompts. Then you turn repeated work into reusable skills. Then you add receipts, evaluation, and ratchet loops so the workflow improves over time. The advanced end state is a fully autonomous agent system: a harness that runs loops, routes context, calls deterministic tools, manages memory, enforces permissions, observes its own work, and leaves an audit trail. - -That advanced end state is covered in `advanced-ai-agent-design-framework.md`. It is the place to go when you are ready to move beyond "how do I prompt this well?" and start asking "how do I design an agent that can safely act, remember, coordinate, and improve?" - -In short: - -- `OSDR-framework.md` helps define the work. -- `ratchet-based-skill-framework.md` helps make the work repeatable and self-improving. -- `advanced-ai-agent-design-framework.md` helps design the full autonomous agent system around the work. - -## Documents In This Repo - -### `OSDR-framework.md` - -The Outcome-Skill-Data-Receipt framework is the easiest place to start. - -It breaks an AI workflow into: - -- `Outcome`: what final state must exist -- `Skill`: how the work should be performed -- `Data`: what information should be used -- `Execution`: the actual run -- `Receipt`: what happened, what was produced, and what was learned - -Use this when you are designing a prompt, automation, recurring task, or agent workflow and want to make the request clearer. - -### `ratchet-based-skill-framework.md` - -This is the deeper skill-design framework. - -It explains how to build skills that improve over time. The key idea is the ratchet loop: - -1. Run the workflow. -2. Validate the output. -3. Find what failed or was ambiguous. -4. Turn that lesson into a durable artifact. -5. Re-run validation so the same problem is harder to repeat. - -A durable artifact might be a test, checklist, schema rule, validation step, anti-pattern, routing example, eval case, or stronger instruction. - -Use this when a prompt or workflow matters enough that "it worked once" is not good enough. - -### `advanced-ai-agent-design-framework.md` - -This is the advanced autonomous-agent design framework and the long-term destination for this repo. - -It takes the repo from reusable prompts and skills into full agent-system design: identity, permissions, context routing, harness loops, deterministic tools, memory, sandboxing, observability, safety, governance, and modular future-proofing. - -Use this when you are designing agents that act over time, call tools, maintain memory, coordinate with other agents, or need checks and balances before high-stakes actions. This is where advanced users can think through the full system around a skill: not just the prompt, but the runtime, context, tools, state, evaluation, permissions, and audit trail required for safe autonomous operation. - -Summary: - -- Starts with identity and trust so the agent knows who it represents and what it is allowed to do. -- Separates the harness, tools, skills, resolvers, memory, and infrastructure into clear layers. -- Defines the loop for autonomous execution: trigger, route, reason, act, store, evaluate, and improve. -- Adds observability, sandboxing, governance, and modularity so the system can scale without becoming fragile. - -### `personas.md` - -This defines useful sub-agent personas for multi-agent workflows. - -The current personas are: - -- Designer -- Architect -- Domain Expert -- Code Expert -- Performance Expert -- Human Advocate - -Use these when you want an AI system to review work from more than one perspective. For example, the Human Advocate can look for confusing instructions, while the Code Expert can focus on implementation risk. - -### `CHANGELOG.md` - -This records notable changes to the framework over time. - -Use it to understand what changed and why, especially as the framework becomes more opinionated about receipts, validation, and durable learning. - -## How To Use This Repo - -You loosely define below, then use the templates in this repo to have AI build the skill. - -### 1. Start With A Real Task - -Pick something you already ask AI to do more than once. - -Examples: - -- summarize meeting notes -- turn a document into action items -- review a code change -- research a market -- create a weekly report -- clean up a spreadsheet -- publish content from draft notes - -Do not start by trying to design a perfect AI system. Start with one repeatable job. - -### 2. Define The Outcome - -Write down what must be true when the work is done. - -Example: - -```text -Outcome: -Create a weekly project summary that lists completed work, blocked items, upcoming deadlines, and recommended next actions. -``` - -The outcome should describe the finished state, not every step. - -### 3. Define The Skill - -Describe how the AI should do the work. - -Example: - -```text -Skill: -Read the source notes, group related items, separate facts from assumptions, identify missing information, and produce a concise summary for a busy project lead. -``` - -This is where you capture method, judgment, rules, and format. - -### 4. Define The Data - -List what the AI is allowed or expected to use. - -Example: - -```text -Data: -- meeting notes from this week -- project task list -- prior weekly summary -- known deadlines -``` - -Clear data boundaries reduce hallucination and confusion. - -### 5. Define Evaluation - -Say how the output should be checked. - -Example: - -```text -Evaluation: -- every deadline must come from the source material -- action items must have an owner when one is known -- assumptions must be labeled -- unanswered questions must be listed separately -``` - -Evaluation is what turns a prompt into a more reliable process. - -### 6. Require A Receipt - -Ask the AI to leave a record of the run. - -Example: - -```text -Receipt: -- inputs used -- assumptions made -- output created -- validation performed -- issues found -- recommended follow-up -``` - -Receipts are useful because future runs can learn from past runs instead of starting from zero. - -### 7. Add The Ratchet - -When something goes wrong, do not only fix the current output. Improve the workflow. - -Example: - -```text -Failure: -The AI included a deadline that was not in the source notes. - -Ratchet: -Add a validation rule: every deadline must include a source reference or be moved to "unconfirmed." -``` - -This is the most important habit in the repo. Every failure should make the next run better. - -## Simple Prompt Template - -You can copy this into an AI tool and fill in the blanks: - -```text -OUTCOME -What final result should exist when this is complete? - -SKILL -What method, role, checklist, or workflow should you use? - -DATA -What information should you use? What should you ignore? - -EVALUATION -How should we check whether the result is correct, useful, and complete? - -RECEIPT -At the end, record what inputs you used, what you produced, what you checked, what failed, and what should improve next time. - -RATCHET -If you discover a recurring mistake, ambiguity, or failure, suggest a durable improvement to this prompt or workflow. -``` - -## Example - -```text -OUTCOME -Produce a clear customer-support response that answers the customer's question, acknowledges their concern, and recommends the next step. - -SKILL -Act as a careful support specialist. Be concise, friendly, and specific. Do not promise anything that is not supported by the policy docs. - -DATA -Use the customer message, the order notes, and the refund policy. Do not invent policy exceptions. - -EVALUATION -Check that the response: -- answers the customer's actual question -- uses a calm and respectful tone -- does not include unsupported claims -- includes the next action - -RECEIPT -Briefly list the source data used, any assumptions, and any policy uncertainty. - -RATCHET -If the policy is unclear, suggest a rule or note that would prevent the same uncertainty next time. -``` - -## For Less AI-Savvy Users - -Think of this repo as a way to make AI instructions less mysterious. - -Instead of asking: - -```text -Can you help me with this? -``` - -You are learning to ask: - -```text -Here is the result I need. -Here is the method to use. -Here is the information to rely on. -Here is how to check your work. -Here is what to record for next time. -``` - -That structure helps the AI produce better work, and it helps you notice when the AI skipped something important. - -## For More Technical Users - -Treat skills like lightweight software artifacts. - -A serious skill should have: - -- a clear contract -- required inputs -- expected outputs -- validation surfaces -- edge cases -- anti-patterns -- state scope -- host capability requirements -- run receipts -- regression artifacts when failures are found - -The stronger version of this repo's philosophy is: - -> Build skills as tested execution contracts: validate the artifact, validate the agent behavior, and turn every failure into a durable guardrail. - -## Suggested Reading Order - -1. Read `OSDR-framework.md` to understand the basic structure. -2. Skim the simple prompt template in this README. -3. Use the template on one real task. -4. Read `ratchet-based-skill-framework.md` when you want to make the workflow repeatable and testable. -5. Read `advanced-ai-agent-design-framework.md` when you want to move from reusable skills into autonomous agent systems. -6. Use `personas.md` if the workflow needs multiple review perspectives. -7. Check `CHANGELOG.md` when you want to see how the framework is evolving. - -## Roadmap - -This repo provides a framework for creating prompts, building reusable skills, and tracking the outputs those skills produce. - -### Determinstic Scripts - -Skill packs like this may also include deterministic scripts that run without calling an AI model. These are regular code files that perform specific tasks reliably and repeatedly. We often create them with AI assistance, but once they exist, they can run without using AI tokens. That matters because tokens cost money, and deterministic scripts are often faster, cheaper, and more reliable for tasks that are clearly defined. - -### Feedback Loops - -When we create a skill, or skill pack that includes many skills and determinstic scripts for a workflow, using the templates in this repo, what we are doing additionally is building a feedback layer into the process of executing skills, which allows AI to use this feedback to improve the skills and process itself. The end goal is not just to have AI execute workflows for us, but to do so in a way where it learns and improves. - -### Routing - -The next evolution of skill packs is routing: deciding which parts of a skill should run as deterministic code, which parts should use a lightweight AI model, and which parts require a stronger model. Some tasks can be handled by simpler, lower-cost models. Other tasks may need more capable reasoning. Good routing helps complete the work with as little token usage as possible while still preserving quality. - -So as you use this repo to design your own skill packs, keep in mind about also creating deterministic skills, creating feedback loops so AI can learn and routing to maximize efficiency. - -### Autonomous Agent Systems - -The advanced path is to wrap skills in a real agent system. - -That means adding: - -- a harness that can run loops and stop when done -- resolvers that decide what context to load and where outputs go -- deterministic tools with clear inputs, outputs, and permissions -- memory that acts as an audit trail -- observability so runs can be replayed and inspected -- sandboxing and governance for risky actions -- modular boundaries so models, tools, prompts, and memory systems can be swapped later - -Use `advanced-ai-agent-design-framework.md` as the checklist for that stage. It is not the first thing most people need, but it is the direction this repo points toward: dependable autonomous agents built from clear skills, tested tools, routed context, durable receipts, and continuous improvement. - -## Skill Packs As Communication Rail - -As consumers increasingly rely on AI as their primary gateway to the internet, information comes to them — they no longer go looking for it. So how does a brand reach them in that world? - -One answer is the skill pack: a downloadable bundle a consumer installs into their AI. Once active, it automatically pulls information from the brand, filters it based on the consumer's preferences, and surfaces only what's relevant to them. - -Think of it as the inverse of email marketing. Instead of a brand pushing a message and hoping the subject line earns an open, the consumer's AI pulls from a richer stream of brand content — new products, events, articles, announcements — and delivers only what that specific person would actually care about. - -The result is a better experience on both sides: brands can publish more freely without worrying about overwhelming people, and consumers get a curated feed without having to wade through irrelevant content. - -## Skill Packs Cloud-Hosted With Local Processing Using MCP - -One possible direction for AI is that desktop and cloud-based AI applications become the primary gateway to the internet. Instead of users searching for information across dozens of websites, their AI applications bring the right information, tools, and workflows to them. - -In this model, organizations publish MCP (Model Context Protocol) servers that expose tools, knowledge, and reusable skill packs. Rather than downloading and periodically updating a local copy of a skill pack, a user's AI can retrieve the latest version directly from the provider's MCP server whenever it is needed. - -The skill pack itself remains generic and version-controlled in the cloud, while the user's private data, preferences, credentials, receipts, and execution history remain local. The AI combines the cloud-hosted skill with the user's local context to perform the work, without requiring the provider to receive or store the user's data. - -This architecture offers several advantages. Skill packs can be improved continuously without requiring users to download updates. Everyone benefits from the latest instructions, bug fixes, and best practices, while maintaining the privacy of their own data. It also enables a single skill pack to be used across many AI applications that support MCP, rather than being tied to a single vendor or platform. - -Viewed this way, an MCP server becomes more than a tool endpoint—it becomes a distribution platform for reusable AI capabilities, allowing organizations to publish living skill packs that are always current while enabling users to execute them securely within their own AI environments. - -## Current Status - -This is an evolving personal framework, not a polished product. - -The repo is useful today as: - -- a prompt-design reference -- a skill-writing template -- a thinking framework for AI workflows -- a foundation for more formal agent systems - -Expect the documents to change as the framework is used on real work and improved through the same ratchet process it recommends. diff --git a/prompt-skill-template/advanced-ai-agent-design-framework.md b/prompt-skill-template/advanced-ai-agent-design-framework.md deleted file mode 100644 index 6da2d0e..0000000 --- a/prompt-skill-template/advanced-ai-agent-design-framework.md +++ /dev/null @@ -1,939 +0,0 @@ -# Advanced AI Agent Design Framework - -This document is a practical framework for designing advanced autonomous AI agents: agents that can run in loops, call tools, manage context, maintain memory, use permissions, leave receipts, and improve over time. - -It extends the prompt-skill-template repo from single reusable skills into a full agent system architecture. - -This is not just a checklist. It is a system for building agents that can be handed over, inspected, improved, and operated by someone else. - -The core idea: - -```text -Intent - -> Identity and permissions - -> Orchestration - -> Context routing - -> Harness loop - -> Skill reasoning - -> Tool execution - -> Output routing - -> Memory and audit trail - -> Evaluation and improvement -``` - -The short version: - -- Skills = thinking -- Resolvers = routing -- Harness = running -- Tools = doing - -An advanced agent builder should be able to: - -1. map a business process end to end -2. spot where an agent can replace or relieve a bottleneck -3. build the agent, tools, harness, routing, and memory around that bottleneck -4. measure whether the agent actually moved the pipeline - -## System Layers - -### Design Layer - -Design defines what the agent is meant to accomplish before code or files are created. - -Key questions: - -- What outcome should exist when the task is complete? -- What artifact should be produced: Markdown, JSON, database row, alert, dashboard update, code change, or something else? -- What does "done" mean? -- Who owns the agent? -- What authority does the agent have? -- Can the agent transact, publish, message, schedule, delete, or modify records? -- Who is responsible when it acts? - -Typical artifacts: - -- `objective.md` -- `agent_identity.json` -- `permissions.json` -- `success_criteria.md` - -### Runtime Layer: Harness - -The harness is the execution engine. - -It answers: - -```text -How does this run? -``` - -The harness: - -- runs the control loop -- calls models -- calls tools -- assembles context -- enforces constraints -- validates tool calls -- logs decisions and actions -- determines when the task is complete - -Think of the harness as factory machinery. It does not define the agent's judgment. It executes the workflow. - -The harness should be thin and tightly scoped to a specific task. It sits between the working system and the AI. It activates the AI to operate inside a controlled area, such as a repo, service folder, data pipeline, or workspace. - -In a repo-style system, the harness may: - -- run the model in a loop -- read specs, tasks, and data-operation files -- write controlled outputs into a service or working directory -- manage context loaded from specs and memory -- enforce safety and permission rules - -Deterministic code still matters. Cron jobs, if/then rules, validators, parsers, and scripts should continue to handle deterministic work. The harness adds AI as the intelligence layer on top of that deterministic substrate. - -Before any tool execution, the harness should: - -- verify agent credentials -- check permission scope -- attach an identity signature or audit record -- enforce sandbox rules -- reject actions outside authority - -Good article on current state of harnesses (July 2026): https://x.com/aparnadhinak/status/2073079029624943040?utm_source=tldrai - - -### Deterministic Layer: Tools - -Tools are reliable capabilities the agent can call. - -They answer: - -```text -What can the agent do repeatably? -``` - -Examples: - -- ingest email, files, API data, or calendar data -- search and filter records -- write or update files -- create database rows -- call external APIs -- run code -- send notifications -- record payments or identity attestations - -Tools should be deterministic, testable, and constrained. A tool should not be a vague instruction. It should have clear inputs, outputs, errors, and permissions. - -Tools do the work. If skills are thinking, tools are doing. - -### Cognitive Layer: Skills - -Skills define how the agent thinks. - -They answer: - -```text -How should the agent interpret, decide, and communicate? -``` - -Skills include: - -- role and behavior rules -- task methodology -- domain-specific judgment -- context-management rules -- output formats -- validation criteria -- escalation rules - -Skills should be modular and reusable. A good skill can move across models, harnesses, and tool stacks. - -Skills are procedural cognition. They encode how the agent should reason, judge, format, validate, and communicate. - -### Identity And Personality Documents - -Advanced agents often need more than a system prompt. Three durable documents are especially useful: - -#### `SOUL.md` - -`SOUL.md` defines who the agent is. - -It can include: - -- voice -- values -- operating principles -- what good output looks like -- what bad output looks like -- tone rules -- judgment rules -- behavioral preferences - -This is not a task prompt. It is a constitution. Write it like you are briefing your smartest friend on how to represent a particular mind, taste, and standard of work. - -#### `USER.md` - -`USER.md` defines who the user is. - -It is not a short bio. It is a deep user model. - -It can include: - -- how the user thinks -- what the user is building -- strengths -- blind spots -- temperament -- preferences -- important relationships and context -- what the user cares about -- what triggers frustration or trust - -The better the agent understands the user, the better it can prioritize, communicate, and serve. - -#### `AGENTS.md` - -`AGENTS.md` defines operational rules. - -It can include: - -- what to check on every message or run -- what never to do -- how to handle failures -- lookup chains -- path rules -- escalation rules -- brain-first protocols -- multi-agent routing rules - -`SOUL.md` says who the agent is. `USER.md` says who the agent serves. `AGENTS.md` says how the agent operates. - -### Context Routing Layer: Resolvers - -Resolvers decide what to load and where outputs go. - -They answer: - -```text -What context should be loaded? -Where should the result be stored or routed? -``` - -Context resolvers select: - -- identity credentials -- permissions -- trust attestations -- relevant files -- prior summaries -- memory entries -- related receipts -- relevant tools and skills - -Output resolvers route results to: - -- Markdown -- JSON -- database rows -- dashboards -- audit logs -- memory stores -- optional signed or immutable records - -Whenever a new skill or tool is added, the resolver layer must know how to find it. A capability exists only if the system can route work to it. - -Resolvers route. They decide which context, skills, tools, memory, and output destinations are relevant to the current task. - -### When A Resolver Should Be Markdown - -Use Markdown when: - -- routing requires judgment -- categories are fuzzy -- logic evolves often -- an LLM should interpret the routing rule - -Example: - -```markdown -# context_resolver.md - -If the task involves analyzing a person, load: - -- person identity document -- relevant social posts -- prior summaries -- recent interaction history - -If the task involves documents, load: - -- source documents -- prior chunk outputs -- related receipts -``` - -Markdown resolvers are flexible, easy to modify, and LLM-readable. - -### When A Resolver Should Be Code - -Use code when: - -- rules are strict -- performance matters -- logic must be exact and repeatable - -Example: - -```python -def resolve_context(task_type): - if task_type == "diarization": - return ["pid.json", "activity.json"] -``` - -Code resolvers are fast, predictable, and testable. - -### System Orchestration Layer - -System orchestration defines who handles the work and how workflows are composed. - -Typical artifact: - -- `AGENTS.md` - -This layer handles: - -- task routing -- multi-agent coordination -- escalation logic -- agent role definitions -- workflow composition - -Think of it as the org chart. It decides who does what, where work goes, and how specialized agents interact. - -### State Layer: Memory - -Memory defines what persists across steps, runs, and long-running workflows. - -It answers: - -```text -What must the agent remember? -How should that memory be retrieved? -How can we trust it later? -``` - -Memory can include: - -- current task state -- full transcripts -- historical outputs -- prior receipts -- trends over time -- source references -- timestamps -- signatures or provenance records - -Advanced agents need memory as an audit trail, not just storage. - -### Infrastructure Layer - -Infrastructure defines where and how the agent runs. - -Questions: - -- Does it run locally, in WSL, in Docker, in a VM, in a microVM, or in the cloud? -- Does each agent need its own sandbox? -- What filesystem, network, and credential access does it have? -- How are secrets stored? -- What happens when a run fails halfway? - -### Evolution Layer - -The system should be modular enough to improve without being rebuilt from scratch. - -Ask whether you can swap: - -- the model -- tools -- prompts -- skills -- resolvers -- memory backend -- sandbox runtime -- evaluation harness - -Future-proofing means every layer has a boundary and a contract. - -## Agent Flow - -```text -Trigger - -> AGENTS.md selects agent or workflow - -> context resolver loads relevant context - -> harness executes loop - -> skill performs reasoning - -> tools execute actions - -> output resolver routes result - -> memory is updated - -> receipt is written - -> evaluator checks completion - -> ratchet improves the system when failures are found -``` - -Triggers can be: - -- cron jobs -- manual starts -- API calls -- webhooks -- file changes -- incoming emails or messages -- scheduled monitors - -## Process Discovery And Handoff - -Before building an autonomous agent, map the human process. - -A useful agent design should identify: - -- the current business process from start to finish -- where work waits, repeats, or gets dropped -- which bottleneck the agent should replace, relieve, or accelerate -- what the agent must read -- what the agent must decide -- what the agent must do -- what the agent must produce -- how success will be measured -- who owns the result after the agent acts - -The goal is not only to build an impressive agent. The goal is to move a real pipeline. - -Useful measurements: - -- cycle time reduced -- handoffs reduced -- manual steps removed -- error rate lowered -- response time improved -- more opportunities processed -- more work completed with the same team -- better follow-through on previously dropped tasks - -If the agent cannot be connected to a bottleneck and a measurement, the design is probably still too abstract. - -## Monetization Lens - -When designing an agent, ask whether the system could eventually be sold, rented, or reused by someone else. - -Possible sources of value: - -- proprietary data collected during use -- a specialized workflow for a niche domain -- reusable skill packs -- deterministic tools -- receipts and eval cases produced over time -- domain-specific memory and context -- integrations that are painful to rebuild - -## Suggested Folder Structure - -```text -/agent-system - /harness - main.py - loop.py - config.yaml - - /identity - SOUL.md - USER.md - agent_id.json - permissions.json - - /skills - summarize.md - diarize.md - match.md - chunk_enrich.md - - /resolvers - context_resolver.md - output_resolver.md - - /agents - AGENTS.md - - /tools - io.py - search.py - db.py - identity.py - wallet.py - attestation.py - - /memory - /working - /persistent - - /data - /inputs - /outputs - /logs - - /sandbox - /runs - - /evals - test_cases.md - failure_log.md - regression_checks.md -``` - -## Agent Build Checklist - -Layer mapping: - -1. Define objective -> design layer -2. Choose model -> harness -3. Define tools -> tools -4. Define data sources -> tools and resolvers -5. Write prompt or skill -> skills -6. Build harness loop -> harness -7. Add memory -> harness, tools, and skills -8. Add context control -> resolvers and harness -9. Define output -> skills and tools -10. Set trigger -> harness -11. Add logging -> harness -12. Add constraints -> harness and skills -13. Make it modular -> all layers - -### 0. Identity And Trust Layer - -This sits above every other layer. - -Define: - -- principal: the human or organization that owns the agent -- agent identity: DID, wallet, key, service account, or other identifier -- permissions: allowed actions, denied actions, approval thresholds -- attestations: reputation, certifications, provenance, prior actions -- payment layer: wallet, billing, payment endpoints, spending limits -- governance guarantees: immutable configs, version control, audit logs - -Possible artifacts: - -```text -/identity - agent_id.json - permissions.json - attestations.json - wallet.json -``` - -Design rule: - -The agent should never act without knowing who it represents, what it is allowed to do, and how its actions will be audited. - -### 1. Objective And Intent - -Start here. Do not skip this layer. - -Define: - -- the job to be done -- the final output artifact -- the success criteria -- what "done" looks like -- what is explicitly out of scope - -If the objective is fuzzy, the agent will wander. - -### 2. LLM Selection - -Choose the model strategy based on task requirements. - -Decide: - -- fast model or deeper reasoning model -- single model or multi-model architecture -- planner/executor split -- critic or evaluator model -- context window requirements -- cost constraints -- latency constraints -- privacy constraints - -Advanced agents often benefit from model routing: use cheaper models for routine work and stronger models for high-stakes planning, synthesis, or verification. - -### 3. Tools Layer - -Define the actions the agent must be able to take. - -Examples: - -- ingest data -- search data -- write summaries -- update files -- call APIs -- run code -- send messages -- schedule events -- verify identity -- record audit events -- send or check payments - -Tool design checklist: - -- Are inputs constrained? -- Are outputs structured? -- Are errors explicit? -- Are permissions enforced? -- Is the tool deterministic? -- Can the tool be tested without an LLM? -- Does the tool leave a receipt or log entry? - -Identity and payment tools may include: - -```text -identity.py - verify_signature() - fetch_agent_credentials() - -wallet.py - send_payment() - check_balance() - -attestation.py - verify_provenance() - record_action() -``` - -### 4. Data And Context Sources - -Define what the agent needs to see. - -Examples: - -- Markdown files -- JSON files -- databases -- APIs -- repo structure -- prior outputs -- logs -- receipts -- user identity documents -- calendar, email, or CRM data - -Decide: - -- What is static context? -- What is dynamic context? -- What should never be loaded? -- What requires trust verification? -- What requires human approval? -- What should be summarized before use? - -Context is not just data. For advanced agents, context should be trusted, scoped, and traceable. - -### 5. Prompt And Instruction Layer - -This is the skill layer. - -Define: - -- system prompt -- role -- rules -- task instructions -- output format -- constraints -- escalation rules -- validation expectations - -Example: - -```text -You analyze emails for trends. -Only use available tools. -Operate within your permission scope. -Log all actions. -Reject tasks outside authority. -Output JSON with: topics, sentiment, anomalies, sources. -``` - -Keep prompts modular. A skill should be reusable across workflows. - -### 6. Harness And Core Orchestration - -The harness is the agent runtime. - -It must handle: - -- control loop: observe, decide, act, repeat -- tool execution: validate, run, return result -- context assembly: prompt, memory, current inputs, retrieved context -- stop conditions: determine when the task is complete -- error handling: retry, escalate, or stop -- logging: record decisions, tool calls, and results -- permissions: reject actions outside scope - -The harness is procedural. It makes the agent run. - -### 7. Memory System - -Define two memory layers. - -Working memory: - -- current task state -- temporary notes -- active plan -- intermediate outputs - -Persistent memory: - -- full transcripts -- prior outputs -- historical receipts -- long-term trends -- user preferences -- reusable lessons - -Memory storage can be: - -- JSON files -- Markdown logs -- SQLite -- Postgres -- vector store -- graph database - -Advanced memory should include: - -- content -- timestamp -- source -- run ID -- agent ID -- signature or provenance record -- confidence or verification state - -Memory should be treated as an audit trail, not just a pile of notes. - -### 8. Context Management - -Context management prevents agents from failing quietly. - -Common failures: - -- token overflow -- noisy context -- stale summaries -- duplicated data -- untrusted content -- missing source references -- irrelevant memory retrieval - -Implement: - -- clipping large outputs -- summarizing history -- deduplicating repeated data -- ranking context by relevance -- loading only verified or trusted sources when risk is high -- separating user instructions from untrusted retrieved content -- preserving source references - -Advanced rule: - -Context should be selected, scoped, and trusted. Loading more is not automatically better. - -### 9. Output Handling - -Define where outputs go and what form they take. - -Possible destinations: - -- Markdown -- JSON -- database -- dashboard -- audit log -- memory store -- external API -- human review queue - -Output checklist: - -- Is it human-readable? -- Is it machine-readable? -- Does it include sources? -- Does it include assumptions? -- Does it include validation status? -- Does it update memory? -- Does it create a receipt? - -Prefer structured outputs for downstream automation, with optional Markdown for human review. - -### 9.1. Sandbox - -Define where the work happens in isolation. - -Sandbox options: - -- local folder sandbox -- WSL -- Docker -- VM -- microVM -- isolated cloud runner - -Sandbox checklist: - -- What files can be read? -- What files can be written? -- Is network access allowed? -- Are secrets available? -- Can subprocesses run? -- Are destructive actions blocked? -- Are credentials scoped per agent? - -Identity isolation: - -- each agent should run with its own credentials -- each agent should have its own permission scope -- high-risk agents should have separate sandboxes -- credentials should not be shared casually across workflows - -### 10. Execution Layer - -Define how the agent is triggered. - -Trigger types: - -- manual trigger -- cron job -- event-driven trigger -- webhook -- API call -- message queue -- file watcher - -Authenticated triggers should verify: - -- token -- signature -- agent identity -- user authorization -- spending or action limits - -This layer is outside the harness, but required for real autonomous operation. - -### 11. Observability, Checks, And Balances - -The system must make agent behavior inspectable. - -Log: - -- who initiated the run -- what agent executed -- what model was used -- what tools were called -- what actions were taken -- what files or records changed -- what errors occurred -- what validation ran -- whether completion criteria were met -- signed proof or audit metadata where appropriate - -Ask: - -- Can you replay a run? -- Can you explain why the agent acted? -- Can you see what context it used? -- Can you detect incomplete work? -- Can you compare runs over time? - -Advanced checker pattern: - -- generator proposes or acts -- critic attacks assumptions -- synthesizer resolves conflicts -- monitor checks constraints, ethics, and scope -- evaluator checks the final artifact against success criteria - -For high-stakes actions, require consensus or explicit approval before: - -- financial transactions -- external communications -- data deletion -- permission changes -- strategic pivots -- irreversible writes - -Adding independent checkers can improve: - -- error detection -- hallucination suppression -- blind spot coverage -- policy compliance -- task completion reliability - -### 12. Safety, Constraints, And Governance - -Define what the agent is not allowed to do. - -Controls: - -- tool permissions -- read/write limits -- file path restrictions -- network restrictions -- spending limits -- approval gates -- immutable agent instructions -- versioned prompts -- external policy enforcement -- sandbox enforcement -- audit logging - -Safety should not live only in the prompt. The harness, tools, filesystem, and execution environment should enforce constraints externally. - -### 13. Modularity And Future-Proofing - -Design every layer so it can be replaced. - -Can you swap: - -- model -- tool -- prompt -- skill -- resolver -- memory backend -- evaluation method -- sandbox -- trigger mechanism -- payment or identity provider - -Future-proofing checklist: - -- Each layer has a clear responsibility. -- Each artifact has a clear contract. -- Skills do not assume one specific model forever. -- Tools are callable outside the LLM. -- Context routing is separate from reasoning. -- Memory is separate from current task context. -- Receipts survive model and harness changes. -- Failures become regression cases or checklist updates. - -The goal is a system where better models, better tools, and better infrastructure can be plugged in without throwing away the framework. - -## Modularity - -Build the pieces in this framework so that you can easily replace them and swap in updated components. The only component that might become long-lived are skills, but even they can be upated as the template in this repo is updated. diff --git a/prompt-skill-template/personas.md b/prompt-skill-template/personas.md deleted file mode 100644 index a7be008..0000000 --- a/prompt-skill-template/personas.md +++ /dev/null @@ -1,19 +0,0 @@ -# Description - -As AI may run sub-agents, this document defines the personas for those sub-agents. Set up clear path where AI agents orchestrate other AI agents. This is where it is done. - -# Sub-Agent Personas - -Each of these "owns" a portion of the docs, and reviews against their own documentation, including suggesting where their own docs need to be adapted. - -## Designer - -## Architect - -## Domain Expert - -## Code Expert - -## Performance Expert - -## Human Advocate diff --git a/prompt-skill-template/ratchet-based-skill-framework.md b/prompt-skill-template/ratchet-based-skill-framework.md deleted file mode 100644 index 6a3dc7b..0000000 --- a/prompt-skill-template/ratchet-based-skill-framework.md +++ /dev/null @@ -1,1225 +0,0 @@ -# Ratchet-Based Skill Framework - -The core lesson is simple: - -> A skill should not just tell an agent what to do. A skill should make the agent better at doing the work every time it runs. - -That means every skill should include a ratchet loop: - -1. Execute the workflow. -2. Test and validate the output aggressively. -3. Identify what broke, what was ambiguous, or what the agent tried to shortcut. -4. Convert that lesson into a durable artifact: a test, validator, eval case, anti-pattern, schema rule, routing example, or skill instruction. -5. Re-run the workflow so the same failure becomes harder to repeat. - -The skill is the operating procedure. The tests and validators are the memory. The ratchet is the loop between them. - -## The Big Idea - -The important insight is not merely "use AI to write tests." The deeper point is that AI changes the economics of verification. - -Humans avoid exhaustive testing because it is tedious, repetitive, and expensive in attention. Edge cases are especially painful because each one may be rare, but together they define whether a system is reliable. - -AI agents are different. They do not get bored writing the fourteenth edge-case test. They can generate test cases, run scripts, inspect failures, refine code, update instructions, and repeat. That means the bottleneck moves from "can a human bear to test this thoroughly?" to "have we clearly defined what correctness means?" - -For skill development, this is the key move: - -> Every important behavior should become a contract, and every contract should have a validation surface. - -A contract can be tested with code, checked with a schema, verified by examples, enforced through a STOP gate, or evaluated by another model. The form depends on the work. The principle is the same. - -## Learnings - -Skills pattern is useful because it treats skills as operational recipes, not passive documentation. - -A strong skill says: - -- when this situation happens -- what workflow to follow -- what guarantees must hold -- what tools to use -- what good output looks like -- what must never happen -- how to validate that the work is actually done - -The best structure is: - -```text -skills/ - RESOLVER.md - manifest.json - conventions/ - quality.md - output-rules.md - identity-policy.md - some-skill/ - SKILL.md -``` - -The split matters: - -- `RESOLVER.md` decides which skill should run. -- `SKILL.md` defines how to perform the work. -- `conventions/` stores shared rules. -- `manifest.json` gives a machine-readable inventory. -- routing examples test whether the resolver chooses correctly. -- conformance tests verify that skills obey their contracts. - -This is the foundation. The ratchet adds a stronger testing and learning loop. - -## Ratchet-Based Skill Anatomy - -Use this template when creating or rewriting skills. - -```md ---- -name: skill-name -description: What this skill does and the specific situations where Codex should use it. ---- - -# Skill Name - -## Contract - -This skill guarantees: - -- ... -- ... -- ... - -## Inputs - -The skill expects: - -- ... - -## Outputs - -The skill produces: - -- ... - -## Skill Shape - -Choose the narrowest shape that fits: - -- `service`: one bounded workflow with clear inputs and outputs -- `system`: multiple services, personas, or phases coordinated together -- `pattern`: reusable coordination structure, such as worker-critic or fan-out -- `responsibility`: standing goal that must remain true over time -- `test`: fixture-driven validation of a skill, system, or output - -## Requires - -This skill requires: - -- ... - -## Ensures - -Before finishing, this skill ensures: - -- ... - -## Capabilities - -Required host capabilities: - -- CLI tools: -- MCP/connectors: -- browser access: -- filesystem access: -- network access: -- subagent support: -- image/document/spreadsheet support: - -If a required capability is unavailable, fail closed or ask the user. Do not silently fake the workflow. - -## State Scope - -Declare what persists: - -- `none`: no state survives the run -- `run`: only this execution keeps scratch state -- `project`: project-level memory/state may be updated -- `user`: cross-project user memory/state may be updated - -Persistent writes must be named explicitly. - -## Host Primitive Adapter - -Map abstract workflow needs to available host actions: - -- spawn subagent: -- ask user: -- read/write files: -- run shell command: -- use browser: -- use connector: -- create durable report: - -If the host cannot provide a required primitive, stop and explain the missing primitive. - -## Workflow - -### Phase 1: ... - -### Phase 2: ... - -### Phase 3: ... - -## Validation - -Before finishing, verify: - -- ... -- ... -- ... - -## Run Receipt - -For serious skills, leave a durable, inspectable receipt. Treat the receipt as the replay/audit record for the skill run, not merely a human-readable final summary. - -The receipt should let a future agent answer: - -- what skill ran -- under what version/context it ran -- inputs used -- assumptions made -- capabilities used -- tool calls or commands executed -- external state changed -- outputs produced -- validations run -- failures found -- fixes applied -- ratchet artifacts added -- unresolved risks -- follow-up recommendations -- how the run could be resumed, audited, forked, or repeated - -If the receipt is compacted into a final response, preserve the full receipt as a file, JSON artifact, test log, or run directory whenever the workflow is important. A final-response summary is a projection of the receipt; it is not the receipt itself. - -## Edge Cases - -Actively test: - -- ... -- ... -- ... - -## Ratchet Rules - -When the skill discovers a recurring mistake, ambiguous case, failed validation, or agent shortcut, convert the lesson into at least one durable artifact: - -- a regression test -- a schema rule -- a validator check -- a routing example -- an eval case -- an anti-pattern -- a STOP gate -- a convention update - -Do not merely fix the current instance. Make the same class of failure harder to repeat. - -## Anti-Patterns - -Do not: - -- ... -- ... -- ... - -## Final Report - -Report: - -- what was produced -- what was validated -- what failed and was fixed -- what ratchet artifact was added or updated - -The final report is for the user. The run receipt is for future agents, auditors, and maintainers. Do not rely on the final response as the only record of a serious skill run. -``` - -## The Ratchet Loop - -Every serious skill should follow this operating loop: - -```text -Run the skill - -> produce output - -> validate output - -> stress edge cases - -> find failures - -> diagnose why they happened - -> update code, process, tests, or skill instructions - -> re-run validation - -> preserve the new lesson as a ratchet artifact -``` - -The important discipline is to never let a failure remain only in human memory. - -Bad: - -> "Remember that this script breaks on empty metadata." - -Good: - -> Add an empty-metadata fixture, update the validator, and add an anti-pattern to the skill. - -Bad: - -> "The agent sometimes invents relationships." - -Good: - -> Add a relationship provenance rule, a validator that rejects unsupported relationships, and an edge-case test with tempting but ungrounded relationship language. - -## Coordination Patterns - -When a skill needs more than one role, do not improvise the collaboration pattern each time. Pick a reusable structure and name it in the skill. - -Useful patterns: - -- `worker-critic`: one agent produces, another critiques, repeat until accepted -- `fan-out`: multiple agents explore independently, parent synthesizes -- `pipeline`: output of one role feeds the next -- `guard`: run a workflow only if preconditions pass -- `fallback-chain`: try safer or cheaper options before expensive ones -- `reviewer-panel`: personas review from different risk lenses -- `map-reduce`: split a large corpus across workers, then aggregate -- `race`: run several approaches and keep the first acceptable result - -Patterns should declare their slots, expected handoffs, invariants, and stopping condition. Personas can then fill the slots without each skill rewriting the coordination rules from scratch. - -## Testing And Validation Surfaces - -A skill can be tested at several levels. Use more than one when the work is important. - -### 1. Schema Validation - -Use when outputs are structured. - -Examples: - -- JSON chunks match the project schema. -- required fields are present. -- enum values are valid. -- relationship types are allowed. -- confidence values are within accepted ranges. - -### 2. Invariant Checks - -Use when certain rules must always hold. - -Examples: - -- `knowledge_id` remains stable across minor edits. -- content hashes match the source text. -- every relationship target resolves. -- every claim has provenance. -- private content is not emitted into public outputs. - -### 3. Golden Fixtures - -Use when known inputs should produce known outputs. - -Examples: - -- a simple source page -- a page with contradictory claims -- a page with quoted beliefs -- a page with no useful entities -- a page with private/pricing/policy content - -The point is not that the full output must be identical every time. The point is that important properties should remain true. - -### 4. Edge-Case Suites - -Use AI to generate exhaustive cases the human would not want to write manually. - -Examples: - -- empty input -- malformed input -- duplicate entities -- near-duplicate chunks -- ambiguous pronouns -- quoted claims -- conflicting dates -- missing source URLs -- circular relationships -- deprecated chunks -- access-rule conflicts - -### 5. Behavioral Tests - -Use when the skill must enforce agent behavior, not just file output. - -Examples: - -- the agent must ask before destructive changes. -- the agent must not skip validation. -- the agent must report uncertainty. -- the agent must not treat inferred assertions as facts. -- the agent must stop when required inputs are missing. - -This can be enforced through STOP gates, final-report requirements, subagent forward tests, or terminal/browser/API harnesses. - -### 6. Routing Tests - -Use when multiple skills exist. - -Examples: - -- "generate chunks" routes to chunk generation. -- "validate my knowledge build" routes to validation. -- "publish the site" routes to publish. -- "extract relationships" routes to relationship extraction. - -Store routing examples in a machine-readable file when possible, such as `routing-eval.jsonl`. - -### 7. Evaluation Cases - -Use when quality is partly judgment-based. - -Examples: - -- is this chunk useful for retrieval? -- is this Q&A faithful to the source? -- did the relationship extraction avoid hallucination? -- did the generated summary preserve nuance? - -For subjective outputs, use rubric-based evals. The ratchet is the recorded baseline: future changes should not score worse. - -## Skill Sections To Add Going Forward - -For your future skills, these sections should become standard. - -### Skill Shape - -Classify the skill before writing it. This prevents every skill from becoming a giant all-purpose prompt. - -```md -## Skill Shape - -Choose the narrowest shape: - -- `service`: one bounded workflow with clear inputs and outputs -- `system`: multiple services, personas, or phases coordinated together -- `pattern`: reusable coordination structure, such as worker-critic or fan-out -- `responsibility`: standing goal that must remain true over time -- `test`: fixture-driven validation of a skill, system, or output -``` - -Use `service` by default. Use `system` only when coordination is part of the work. Use `responsibility` when the skill protects an ongoing condition rather than producing a one-time artifact. - -### Contract - -Define what the skill guarantees. - -Example: - -```md -## Contract - -This skill guarantees: - -- every chunk has stable identity fields -- every factual claim has provenance -- generated Q&A is grounded in source material -- uncertain enrichments are stored as proposed assertions, not facts -- validation is run before final output -``` - -### Requires And Ensures - -Use contract language that is easy for agents to extract and easy for humans to review. - -```md -## Requires - -The skill must have: - -- `input_name`: what the caller or upstream workflow must provide -- `tool_name`: required tool, permission, connector, or local file - -## Ensures - -The skill guarantees: - -- `output_name`: concrete output or postcondition -- each produced artifact passes the declared validation surface -``` - -`Requires` is the handoff protocol. `Ensures` is the promise. If either side is vague, the skill will drift. - -### Capabilities - -Declare host capabilities explicitly. - -```md -## Capabilities - -Required capabilities: - -- CLI tools: -- MCP/connectors: -- browser access: -- filesystem access: -- network access: -- subagent support: -- image/document/spreadsheet support: - -If a required capability is unavailable, fail closed or ask the user. Do not silently fake the workflow. -``` - -Capabilities are not the same as inputs. Inputs are data the workflow consumes. Capabilities are powers the host must provide. - -### State Scope - -Declare what survives the run. - -```md -## State Scope - -- `none`: no state survives the run -- `run`: only this execution keeps scratch state -- `project`: project-level memory/state may be updated -- `user`: cross-project user memory/state may be updated - -Persistent writes: - -- ... -``` - -This prevents accidental memory pollution and makes durable skill behavior reviewable. - -### Host Primitive Adapter - -Every skill that depends on the environment should map abstract needs to concrete host actions. - -```md -## Host Primitive Adapter - -- spawn subagent: -- ask user: -- read/write files: -- run shell command: -- use browser: -- use connector: -- create durable report: - -If the host cannot provide a required primitive, stop and explain the missing primitive. -``` - -This makes skills more portable across Codex, Claude, and future agent hosts. - -### Validation - -Define how the agent proves the contract was met. - -Example: - -```md -## Validation - -Before finishing: - -1. Validate output against the schema. -2. Check ID stability and content hashes. -3. Verify relationship targets resolve. -4. Confirm provenance exists for every claim. -5. Run edge-case fixtures when the skill or script changed. -6. Report failures and fixes. -``` - -### Edge Cases - -Make edge cases explicit so the agent does not only test the happy path. - -Example: - -```md -## Edge Cases - -Test against: - -- empty source content -- duplicate headings -- ambiguous entities -- quoted beliefs -- unsupported relationship claims -- private content -- deprecated or superseded chunks -``` - -### Ratchet Rules - -Force learning to become durable. - -Example: - -```md -## Ratchet Rules - -If validation fails, do not only patch the output. Identify the class of failure and update at least one of: - -- the skill instructions -- a validator -- a regression fixture -- a schema rule -- an anti-pattern -- a routing example -- a shared convention - -Then re-run validation. -``` - -### Run Receipt - -For serious skills, require an inspectable receipt. - -```md -## Run Receipt - -Treat the receipt as the replay/audit record for the skill run, not merely a human-readable final summary. - -Record: - -- skill name -- skill version or source -- executor context -- user request -- inputs used -- assumptions made -- capabilities used -- tool calls or commands executed -- external state changed -- outputs produced -- validations run -- failures found -- fixes applied -- ratchet artifacts added -- unresolved risks -- follow-up recommendations -- resume notes -``` - -The receipt can be a Markdown report, JSON artifact, test log, run directory, or final-response block. For important workflows, preserve the full receipt outside the final response. The key is that future agents can inspect what happened without reconstructing it from memory. - -### Receipt Vs Final Report - -The final report is for the user. - -The run receipt is for future agents, auditors, and maintainers. - -Do not rely on the final response as the only record of a serious skill run. If the workflow changed files, made decisions, ran validations, skipped validations, discovered failures, or added ratchet artifacts, preserve those facts in the receipt. - -### Responsibilities - -Use responsibility mode when the skill protects an ongoing condition, not just a one-time output. - -```md -## Responsibility - -This responsibility keeps true: - -- goal: -- continuity: -- criteria: -- constraints: -- fulfillment: -``` - -Definitions: - -- `goal`: what must remain true -- `continuity`: how time, recurrence, or events qualify the obligation -- `criteria`: what counts as healthy -- `constraints`: what must stay bounded or prohibited -- `fulfillment`: what workflow restores health - -Examples: - -- Skill docs remain fresh with generated templates. -- All skills keep validation and ratchet sections. -- Cloned reference repos are periodically pulled and summarized. -- Knowledge-build outputs remain schema-valid. - -### Triggers - -For repeatable workflows, define when the skill should run. - -```md -## Triggers - -Run this skill when: - -- user asks: -- file changes: -- scheduled review: -- new repo is cloned: -- validation fails: -- release/shipping gate occurs: -``` - -Triggers make automations and recurring reviews less ad hoc. - -### Anti-Patterns - -Name the shortcuts the agent is likely to take. - -Example: - -```md -## Anti-Patterns - -Do not: - -- copy the full CIS envelope into every simple chunk -- invent relationships without provenance -- change stable IDs after minor wording edits -- promote inferred assertions into facts -- skip validation because the output "looks right" -- treat a clean script run as proof that semantic quality is good -``` - -## Recommended Skill System For Your Work - -For your CIS and knowledge-structuring work, a system could look like: - -```text -skills/ - RESOLVER.md - manifest.json - routing-eval.jsonl - conventions/ - cis-field-selection.md - identity-versioning.md - relationship-ontology.md - assertion-ledger.md - output-json.md - validation-ratchet.md - publishing.md - author-content-structuring/ - SKILL.md - cis-subset-selection/ - SKILL.md - chunk-json-generation/ - SKILL.md - qa-generation/ - SKILL.md - relationship-extraction/ - SKILL.md - ai-index-generation/ - SKILL.md - publish-static-site/ - SKILL.md - validate-knowledge-build/ - SKILL.md -``` - -The most important new skill is: - -```text -validate-knowledge-build/ - SKILL.md -``` - -That skill is the ratchet engine for the whole system. - -It should check: - -- every chunk has required IDs -- every content hash matches -- every relationship target resolves -- every selected CIS field is allowed by the project schema -- every generated Q&A maps back to source material -- every assertion has provenance and confidence -- uncertain enrichment is marked as proposed, not fact -- paid/private/public access rules are respected -- deprecated chunks have supersession lineage -- every `ai-index` entry points to a real file -- routing examples still select the right skills - -## Skill Development Workflow - -Use this workflow when building or improving a skill. - -### Phase 1: Define The Contract - -Ask: - -- What must this skill always guarantee? -- What would count as a dangerous failure? -- What should never be left to human memory? - -Write the contract before optimizing the workflow. - -### Phase 2: Define The Happy Path - -Write the normal workflow in clear phases. - -Each phase should have: - -- a purpose -- expected inputs -- expected outputs -- completion criteria - -### Phase 3: Generate Edge Cases - -Ask the agent to generate adversarial and boring edge cases. - -Use categories like: - -- missing data -- malformed data -- duplicate data -- contradictory data -- ambiguous language -- privacy-sensitive content -- quoted or attributed claims -- large inputs -- tiny inputs -- stale or deprecated content - -### Phase 4: Build Validators - -Turn the contract into checks. - -Use deterministic validation whenever possible: - -- schema validation -- ID checks -- hash checks -- link checks -- access-rule checks -- relationship-resolution checks - -Use rubric/eval validation where deterministic checks are not enough: - -- faithfulness -- usefulness -- judgment quality -- source grounding -- nuance preservation - -### Phase 5: Forward-Test The Skill - -Run the skill on realistic tasks. - -For important skills, use fresh-agent forward tests: - -- give the tester only the skill and realistic input -- do not leak the expected answer -- inspect whether the skill caused the right behavior -- record where the tester struggled - -### Phase 6: Ratchet The Lessons - -For every failure, decide where the lesson belongs: - -- Skill instruction: if the agent misunderstood the workflow. -- Anti-pattern: if the agent took a predictable shortcut. -- Validator: if the failure can be detected deterministically. -- Fixture: if the failure needs a concrete regression example. -- Eval rubric: if the failure is qualitative. -- Convention: if the lesson applies across multiple skills. -- Resolver/routing eval: if the wrong skill was selected. - -### Phase 7: Re-Run Validation - -Do not stop after editing the skill. - -Re-run the relevant tests, validators, or forward test. The ratchet only works if the new rule actually catches or prevents the failure. - -## The Practical Standard - -For future skills, use this standard: - -> No serious skill is complete until it defines its contract, edge cases, validation method, anti-patterns, and ratchet rule. - -For code-generating or output-generating skills, the stronger standard is: - -> The skill must produce or invoke tests that try to break its own output. - -This is the main learning from Garry Tan's article applied to your work. - -AI should not only create the artifact. AI should attack the artifact, find where it breaks, explain why, and improve the skill so the next run starts from a higher floor. - -## Minimal Checklist For Any New Skill - -Before calling a skill done, confirm: - -- the trigger description is clear -- the skill shape is explicit -- the contract is explicit -- requires and ensures are named -- the workflow is phased -- expected outputs are named -- capabilities are declared -- state scope is declared -- required host primitives are mapped -- validation is required -- edge cases are listed -- anti-patterns are listed -- ratchet rules are present -- serious skills produce a run receipt -- recurring workflows define responsibilities and triggers -- shared conventions are referenced instead of duplicated -- any scripts have been run at least once -- any structured outputs have schema checks -- any important failure produced a durable regression artifact - -## The One-Sentence Version - -Build skills as execution contracts with built-in verification, then use every failure to permanently raise the floor. - -## More Learnings - - ->Do not treat skills as Markdown prompts, but as software artifacts with CI, E2E tests, evals, freshness checks, and behavioral contracts. - -This is the practical version of the ratchet. The skill itself gets tested. The output gets tested. The agent behavior caused by the skill gets tested. - -### 1. Skills are generated artifacts, not hand-maintained blobs - -Many skills have both: - -```text -SKILL.md.tmpl -SKILL.md -``` - -The template is the source of truth. The generated `SKILL.md` is what the agent actually reads. Tests that generated files are fresh, unresolved placeholders are gone, and generated variants exist for the supported agent hosts. - -Learning for us: - -- If a skill has repeated shared sections, generate them. -- If a skill is generated, test freshness. -- If a shared convention changes, regenerate all affected skills. -- Do not rely on humans remembering to copy changes across skills. - -### 2. Validation is tiered by cost - -Use a tiered validation model: - -```text -Tier 1: Static validation -Tier 2: Real agent E2E runs -Tier 3: LLM-as-judge quality evals -``` - -This is excellent because not every validation needs to be expensive. - -Learning for us: - -- Run cheap deterministic checks every time. -- Run realistic workflow tests before important changes. -- Use LLM judges only when quality is subjective. -- Do not make the expensive eval the first line of defense. - -### 3. The skill files themselves are tested - -Test things like: - -- valid browser commands in skill examples -- valid command flags -- no unresolved template placeholders -- required trigger phrases -- documentation inventory consistency -- no private maintainer paths leaked into skills -- cross-skill path consistency -- generated Codex/Claude variants exist -- expected sections are present - -Learning for us: - -> A skill should have a test suite for the skill instructions themselves. - -This is a major upgrade to the framework. We should not only test the thing the skill produces. We should test whether the skill document still contains the instructions, gates, triggers, examples, and validation sections that make the skill work. - -### 4. The coverage audit is the strongest ratchet pattern - -Test coverage audit does not merely ask, "Did tests run?" - -It asks the agent to map: - -- changed code paths -- user flows -- conditionals -- error handlers -- empty states -- boundary cases -- integration points -- E2E-worthy flows -- eval-worthy LLM behavior - -Then it marks gaps and generates tests for them. - -Learning for us: - -> Coverage is not just line coverage. Coverage is behavioral surface coverage. - -For CIS, knowledge, and skill work, this means we should map: - -- workflow paths -- data paths -- user-facing paths -- transformation paths -- validation paths -- failure paths -- ambiguous interpretation paths - -Each path should either be tested, validated, explicitly accepted as uncovered, or turned into an eval case. - -### 5. Test agent behavior, not just code - -One test exists because an agent previously skipped the interactive review flow and dumped all findings at once. The regression test checks whether the agent actually fires an interactive question before finishing. - -That is extremely important. - -The tested behavior was not "does a function return the right value?" - -It was: - -> Did the agent follow the behavioral contract of the skill? - -Learning for us: - -Some skills need behavioral tests. Examples: - -- Did the agent ask before destructive actions? -- Did the agent validate before finishing? -- Did the agent avoid promoting uncertain assertions to facts? -- Did the agent stop at a required gate? -- Did the agent use the right skill instead of answering directly? -- Did the agent create a regression artifact after finding a failure? - -### 6. Skillify is a model skill-building workflow - -`/skillify` flow is especially relevant. It codifies a browser scraping prototype into a permanent skill only after: - -1. confirming there was a real prior prototype -2. capturing a fixture -3. generating `script.ts` -4. generating `script.test.ts` -5. staging the skill in a temporary directory -6. running the test -7. asking for approval -8. committing or discarding atomically - -Learning for us: - -> A new skill should be staged, tested, and approved before it becomes part of the permanent skill library. - -This is stronger than "write a skill and try it later." The skill creation workflow itself should have gates. - -### 7. QA and Ship make the ratchet operational - -`/qa` does not just find bugs. It fixes them, re-tests them, classifies the fix, and then creates regression tests when appropriate. - -`/ship` audits coverage, generates tests for gaps, blocks or asks before shipping below thresholds, and writes a reusable test plan artifact. - -Learning for us: - -Every important workflow should leave behind a reusable testing artifact: - -- test plan -- validation report -- coverage diagram -- failed-case fixture -- regression example -- eval baseline -- quality score - -The artifact becomes memory for the next skill invocation. - -## Additions To The Skill Template - -Going forward, add these sections to serious skills. - -### Test Surface - -Define what can be tested for this skill: - -```md -## Test Surface - -This skill can be tested through: - -- Static checks: -- Schema checks: -- Invariant checks: -- Fixture tests: -- Behavioral/E2E tests: -- LLM-as-judge evals: -- Routing tests: -- Freshness checks: -``` - -Examples: - -- Static checks: required sections exist, no unresolved placeholders, valid command examples. -- Schema checks: JSON output conforms to schema. -- Invariant checks: IDs remain stable, relationship targets resolve. -- Fixture tests: known input produces valid output properties. -- Behavioral/E2E tests: agent asks before proceeding, runs validation, stops at gates. -- LLM-as-judge evals: output is faithful, useful, complete, or clear. -- Routing tests: user request selects the correct skill. -- Freshness checks: generated files match templates. - -### Coverage And Edge-Case Audit - -For code-generating, data-generating, or workflow-heavy skills: - -```md -## Coverage And Edge-Case Audit - -Before finishing, map: - -- code paths or workflow paths -- user-facing flows -- failure modes -- edge cases -- existing tests or validators -- uncovered gaps - -Mark each gap as: - -- [UNIT] -- [E2E] -- [EVAL] -- [SCHEMA] -- [MANUAL] - -For every uncovered gap, either: - -1. create a test or validator, -2. add it to the test plan, -3. mark it intentionally uncovered with rationale, -4. or ask the user before proceeding. -``` - -### Regression Rule - -```md -## Regression Rule - -If this skill discovers that something previously worked and now breaks, create a regression artifact immediately. - -Do not merely fix the current output. - -Acceptable regression artifacts: - -- test fixture -- unit or integration test -- validation rule -- routing example -- eval case -- anti-pattern -- STOP gate -- shared convention update -``` - -### Validation Tiers - -```md -## Validation Tiers - -Tier 1: Fast deterministic checks run every time. - -Examples: -- schema validation -- required-section checks -- command syntax checks -- invariant checks -- placeholder checks - -Tier 2: Realistic workflow or agent E2E tests run before important changes. - -Examples: -- run the skill on a fixture -- spawn a fresh agent with the skill -- verify that required files are created -- verify that required gates are hit - -Tier 3: LLM-as-judge or cross-model evals run when quality is subjective. - -Examples: -- faithfulness scoring -- usefulness scoring -- clarity scoring -- cross-model disagreement review -- baseline regression checks -``` - -### Skill Freshness And Inventory - -```md -## Skill Freshness And Inventory - -If this skill is generated from templates, verify: - -- generated files are fresh -- placeholders are resolved -- command examples still match real commands -- docs mention the skill -- routing examples still select the skill -- no private/local-only paths leaked into the skill -- shared conventions are referenced instead of duplicated -``` - -## Three Levels Of Skill Quality - -Add an important distinction. We should judge future skills on three levels: - -### 1. Artifact Quality - -Did the generated thing work? - -Examples: - -- code compiles -- JSON validates -- chunks are well-formed -- relationships resolve -- browser flow succeeds -- document renders - -### 2. Process Quality - -Did the agent follow the intended workflow? - -Examples: - -- asked before destructive changes -- ran validation before final output -- checked edge cases -- used the browser when required -- stopped at STOP gates -- produced the required final report - -### 3. Ratchet Quality - -Did any failure become durable memory? - -Examples: - -- added a regression test -- added a fixture -- added an anti-pattern -- updated a validator -- updated a routing example -- updated a convention -- added an eval baseline - -This third level is the main Garry Tan learning. The skill is not done when the output works once. The skill is done when the next agent is less likely to repeat the same mistake. - -## Updated One-Sentence Version - -Build skills as tested execution contracts: validate the artifact, validate the agent behavior, and turn every failure into a durable guardrail that raises the floor for the next run.