design-agent-reward-functions
Skill4 starsChanged 3 months agoMITView on GitHub
WHEN/WHERE/WHO: [Scheduling: Use when designing the exit criteria and validation logic for an autonomous AI agent's execution loop.] HOW: [Structural: Use this SKILL to translate classic BDD Gherkin scenarios into Verifiable Reward Functions that act as hard constraints.] WHY: [Scheduling: Autonomous agents suffer from reasoning drift and hallucinations. Explicit Given/When/Then boundary checks prevent runaway execution.]
In this repository61 other files it gives its agents.
- activate-personalSkill
- analyze-with-tactics-questionnairesSkill
- apply-agile-testing-quadrantsSkill
- apply-architectural-tacticsSkill
- apply-attribute-driven-designSkill
- apply-fundamentals-of-data-visualizationSkill
- apply-oopsi-modelSkill
- apply-screenplay-patternSkill
- apply-specification-by-exampleSkill
- blog-topic-discoverSkill
- build-agent-memory-systemsSkill
- build-business-objectives-modelSkill
- build-data-dictionarySkill
- build-feature-treeSkill
- comment-alive-test-driven-developmentSkill
- conduct-event-stormingSkill
- create-ecosystem-mapSkill
- create-living-documentationSkill
- create-skill-from-bookSkill
- CREATING-SKILL-TEMPLATESkill
- define-architectural-driversSkill
- define-bounded-contextsSkill
- define-ubiquitous-languageSkill
- design-agentic-screenplay-modelSkill
- design-agent-perception-layersSkill
- design-agent-planningSkill
- design-agents-using-patternsSkill
- design-architecture-viewpointsSkill
- design-autonomous-ai-interfacesSkill
- design-ddd-aggregatesSkill
- design-tool-use-sandboxingSkill
- document-architectural-decisionsSkill
- document-legacy-codebaseSkill
- doc-with-usage-exampleSkill
- draft-srs-documentSkill
- elicit-requirements-modelsSkill
- evolve-skill-with-wikiSkill
- extract-business-rulesSkill
- facilitate-example-mappingSkill
- facilitate-user-story-mappingSkill
- implement-agent-observabilitySkill
- implement-agent-reflectionSkill
- improve-existing-skillSkill
- improve-user-storySkill
- managing-ai-projectsSkill
- orchestrate-multi-agent-collaborationSkill
- prioritize-requirementsSkill
- review-c4-modelSkill
- review-data-engineeringSkill
- save-as-skillSkill
- scaffold-cmake-cxx-sanitize-gtest-envSkill
- skill-commonSkill
- task-commit-triggerSkill
- test-case-with-demoSkill
- test-case-with-readmeSkill
- test-driven-developmentSkill
- UnitTesting-convert2CaTDDSkill
- update-my-resumeSkill
- update-spec-contextSkill
- validate-requirements-criteriaSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter …
- Distinctive: line 45
Transfer Check: Verify the workflow still works for file, API, and database state changes rather than only one verification medium.
- Distinctive: line 46
Stop Rule: If the task goal cannot be tied to programmatic evidence, stop and tell the user the workflow lacks a safe reward function.
- Very specific: line 49
Observable Evidence: Every Then clause MUST correspond to an observable state change in the system (e.g., a file written, a database row …
- Very specific: line 51
DO NOT use subjective or qualitative Then clauses (e.g., Then the code should be clean).
- Distinctive: line 52
DO NOT allow the agent to evaluate its own success purely via an LLM call.
- Distinctive: line 55
If the expected outcomes cannot be programmatically verified, stop and inform the user that the task lacks a Verifiable Reward and is …
- Distinctive: line 90
Do they include stop conditions that prevent hallucinated success?
- Very specific: line 94
Verify that all Then statements can be executed by a deterministic script without human or LLM intervention.
- Distinctive: line 95
If verification passes, output the Verifiable Reward Function definition.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Design Agent Reward Functions
Common Contract (Load First)
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter rules, anti-pattern guidance, and the Review In Mind loop in review-in-mind. This skill adds only domain-specific rules below.
Who
AI Agents, Test Engineers, and System Architects building autonomous execution loops.
What
Elevates classic BDD Gherkin into strict boundary constraints (Reward Functions) for autonomous agents. It forces the creation of deterministic Given/When/Then checks that act as the exact exit criteria for an agent, ensuring it stops executing once the goal is achieved, and preventing it from hallucinating success.
When
Invoke this skill when defining the "Done" state for an agentic task, when an agent loop is suffering from infinite recursion, or when you need to formally specify the success criteria for an autonomous workflow.
Near-miss: Do not use this to write UI testing scripts (use write-declarative-executable-specifications instead).
Where
Applies to the validation phase of an agentic workflow, typically within the Evaluation or Verification node of a state machine (e.g., LangGraph).
Why
In classic SE, Gherkin was a communication tool for humans. In Agentic SE, Gherkin is the mathematical boundary that stops an agent from drifting. Without a Verifiable Reward Function, an agent relies on internal self-reflection to determine success, which is highly prone to hallucination.
Inputs
- Agent Task: The goal the agent is attempting to achieve.
- System State: The expected state of the system after execution.
Output (Logical Evidence)
- A deterministic
Given/When/Thenscenario. - A mapped set of programmatic checks (the "Verifiable Reward") that correspond to the
Thenclauses.
Optimization Readiness
- Failure Signals: Reward definitions remain subjective,
Thenclauses cannot be observed programmatically, the agent is allowed to self-certify success, or the scenario omits critical preconditions. - Evidence To Collect: Given/When/Then scenarios, mapped checks, failed validations, and examples where a reward function caught or missed execution drift.
- Safe Mutation Boundaries: Refine scenario wording, reward-mapping guidance, and deterministic check examples without changing the core requirement that success be externally verifiable.
- Acceptance Criteria: Accept revisions only if every success condition maps to observable evidence and the workflow rejects subjective or purely LLM-based validation.
- Rejected Revision Handling: Record weak
Thenclauses, pseudo-deterministic checks, and self-evaluation shortcuts so they are not repeated. - Transfer Check: Verify the workflow still works for file, API, and database state changes rather than only one verification medium.
- Stop Rule: If the task goal cannot be tied to programmatic evidence, stop and tell the user the workflow lacks a safe reward function.
Constraints (Logical Boundaries)
- Observable Evidence: Every
Thenclause MUST correspond to an observable state change in the system (e.g., a file written, a database row added, an API 200 OK response). - Anti-Pattern Mapping:
- DO NOT use subjective or qualitative
Thenclauses (e.g.,Then the code should be clean). - DO NOT allow the agent to evaluate its own success purely via an LLM call. The reward MUST be verified by a deterministic tool or script.
- DO NOT use subjective or qualitative
One More Thing
If the expected outcomes cannot be programmatically verified, stop and inform the user that the task lacks a Verifiable Reward and is unsafe for autonomous execution.
How (The 4-Phase Refinement Protocol)
Phase 1: Define the Context (Given)
Input State: An Agent Task.
- Determine the necessary preconditions for the agent to begin execution.
- Formulate these as
Givenstatements. Output State: A deterministic starting state.
Phase 2: Define the Action (When)
Input State: Preconditions defined.
- Define the specific action or sequence of actions the agent will perform.
- Formulate this as a
Whenstatement. Ensure it describes what the agent does, not how it does it. Output State: The core action defined.
Phase 3: Define the Verifiable Reward (Then)
Input State: Action defined.
- Identify the observable, programmatic evidence that proves the action was successful.
- Formulate these as
Thenstatements. - Branch: If a
Thenstatement relies on subjective evaluation (e.g., an LLM checking its own work), reject it and demand a deterministic check. Output State: A set of Verifiable Rewards.
Phase 4: Construct the Exit Condition
Input State: Verifiable Rewards defined.
- Wrap the
Thenstatements into a script or tool that returns a booleanTrue/False(or a specific score). - Inject this script into the agent's evaluation loop as the hard exit condition. Output State: A hardened agent execution loop protected against reasoning drift.
Review In Mind (ReviewInMindGenie)
Execute the common review loop in review-in-mind before delivering.
Review lens for this skill:
- Are reward functions strict Given/When/Then checks that can be evaluated deterministically?
- Do they include stop conditions that prevent hallucinated success?
- Is there an exit criterion for every terminal state (success, failure, retry)?
Validation (Verifiable Rewards)
- Verify that all
Thenstatements can be executed by a deterministic script without human or LLM intervention. - If verification passes, output the Verifiable Reward Function definition.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

