Using Scripts
Scripts give an agent the ability to take actions — running code, calling APIs, reading files — rather than just reasoning about them. Scripts live inside individual skills, not at the harness level.Where scripts live
Scripts belong in thescripts/ subdirectory of a skill, not in the harness root:
Referencing scripts from SKILL.md
InSKILL.md, tell the agent when and how to invoke the script:
What belongs in scripts vs. in the SKILL.md body
| Belongs in scripts | Belongs in SKILL.md |
|---|---|
| Code that calls an external API | When and why to call the API |
| File I/O, database queries | What data to look for and how to interpret it |
| Computations on structured data | How to present results to the user |
| Authentication and credential handling | Which credential or environment variable to use |
SKILL.md handles reasoning.
Script conventions
These aren’t enforced by the spec, but they produce more reliable agent behavior:- Use stdin/stdout. Scripts should read input from command-line arguments or stdin and write results to stdout. This makes them easy for agents to invoke and parse.
- Exit with a non-zero code on failure. Agents can detect failure and reason about it if the script communicates errors through exit codes.
- Print structured output. JSON or simple key-value output is easier for agents to parse than prose.
- Keep scripts focused. One script per distinct action; let the agent decide which script to call, not the script itself.
- Don’t embed credentials. Use environment variables. Document which variables are required in
SKILL.md.
Harness-level scripts
The spec does not define ascripts/ directory at the harness root. If you find yourself wanting harness-level scripts, consider whether they belong in a shared skill that multiple other skills depend on, or whether they represent a new atomic capability that should become its own skill.