refactor-for-determinism
Refactor for Determinism
Build reliable skills by separating deterministic steps from judgment-based steps.
Core Principle
Deterministic steps belong in scripts. Use SKILL.md to orchestrate the workflow and reserve judgment for the non-deterministic parts.
Workflow
1. Identify Deterministic vs Non-Deterministic Work
For each step in the skill:
- Deterministic: repeatable, mechanical, or validation-heavy steps → script candidates
- Non-deterministic: judgment, interpretation, creative choices → keep in SKILL.md
Examples of deterministic steps:
- Running quality checks
- Verifying clean git state
- Updating version strings
- Promoting CHANGELOG sections
- Collecting diff context for review
Examples of non-deterministic steps:
- Writing changelog content
- Selecting a solution approach
- Code review judgments
- Deciding release timing
2. Design Scripts for Deterministic Steps
For each deterministic step:
- Create a script in
scripts/within the skill directory - Make it self-contained with clear error messages
- Validate inputs and exit non-zero on failure
- Prefer small, single-purpose scripts
3. Update SKILL.md to Use Scripts
- Replace manual command lists with script calls
- Reference scripts using relative paths:
scripts/... - Keep judgment steps explicit in prose
4. Document Boundaries
Make the line between scripted and non-scripted steps obvious:
- Use section headers like "Deterministic Steps" and "Judgment Steps"
- Call out where human/agent judgment is required
Output Format
## Determinism Audit
### Deterministic Steps (script candidates)
- [Step] → [script name]
### Non-Deterministic Steps (keep in SKILL.md)
- [Step] → [why it needs judgment]
### Script Plan
- scripts/[name] - [purpose, inputs, outputs]
### SKILL.md Updates
- [Where to call each script]
Common Mistakes
| Mistake | Fix |
|---|---|
| Scripting judgment | Keep decision-making in SKILL.md |
| One giant script | Split into small, focused scripts |
| Silent failures | Print clear errors and exit non-zero |
| Hardcoded paths | Use repo-relative paths |
| Forgetting SKILL.md updates | Always wire scripts into instructions |
What NOT to Do
- Do NOT hide decisions inside scripts
- Do NOT make scripts that require manual editing
- Do NOT mix multiple responsibilities into one script
- Do NOT add extra documentation files beyond SKILL.md
More from kasperjunge/agent-resources
code-review
Use when reviewing code changes before committing, after implementing features, or when asked to review. Triggers on staged changes, PR reviews, or explicit review requests.
15brainstorm-solutions
Generate multiple viable solution options after research is complete, before converging on a single approach. Use when you need to explore the solution space, ask clarifying questions, and produce 3-5 distinct options to consider.
15commit-work
Use when work is complete and ready to commit. Triggers after code review passes, when asked to "commit", "save this", or "wrap up". Runs quality checks, updates changelog, creates commit.
14design-solution
Converge on a single recommended solution after brainstorming options. Use when you have multiple candidate approaches and need to analyze trade-offs, select one, and define decision criteria before planning.
14research-codebase
Research a task, problem, bug, or feature by exploring the codebase. Use when starting new work, encountering bugs, or needing to understand how existing implementation relates to a task. Triggers on "research", "investigate", "look into", or requests to understand implementation before making changes.
14ost
Use when running or maintaining an Opportunity Solution Tree (OST) workflow with a lightweight graph store and CLI. Provides a single entry skill that routes to outcome, opportunity, solution, and assumption/experiment phases via progressive disclosure.
13