Dayward AIWeChat Mini Program
Agent Skills in 7 Days: Turn Experience Into Reusable Capability
Week 1 · D4🔒 LockedAbout 5 hours

Skills With Scripts: Executable Attachments, Dependencies and Sandboxing, Cross-Platform Support, and Breaking Down Document-Handling Skills

When a skill should ship a script instead of more instructions, how to make a script's dependencies self-contained, how to design its interface for an agent, and how a document-handling skill breaks into plan, then validate, then execute.

Today's goals 0/3

Sign in to tick these off and save your progress.

Today's Goals

  1. Judge whether a piece of logic belongs in the SKILL.md body or should be distilled into a script under scripts
  2. Write an agent-friendly script that is self-contained, non-interactive, produces structured output, and gives self-correctable error messages
  3. Break a document-handling task into a three-step flow: plan first, then validate, then execute

Yesterday's design method left a thread hanging: that crucial validation inside plan-validate-execute is itself a piece of code. Today covers a skill's third directory, scripts/, in full — when to switch from writing instructions to writing code, what makes a script one built for an agent, and where exactly the risk lies in letting a model run your script. Once you have read the walkthrough and finished the lab, scroll back to the top and tick off the three goals.

Plain-Language Walkthrough

When to write a script

One page of the work instructions in the filing cabinet says "add up the thirty amounts in this table, to within one cent." You can spell out on that page how the addition is done, or you can clip a calculator to it. A skill's scripts/ directory is that calculator clipped to the page.

Three criteria, and hitting any one means write a script.

First, the same logic has been reinvented a third time. You ran a skill for a few rounds, looked back at its execution traces, and found the model writing almost the same code from scratch every time — parsing the same format, drawing the same chart, running the same validation. Written fresh each time means possibly written differently each time, and it costs tokens and time every time. Turning it into a tested script is one investment for a lasting return.

Second, the result must be identical to the letter. Validation, format conversion, hash computation — there is exactly one right answer. Having the model follow instructions means every run can drift; having it run a script means the result is deterministic. Deterministic tasks go to code and judgment tasks stay with the model, which is the baseline of the division.

Third, one command is complex enough to be hard to get right first time. A command with seven flags that pipes three times in a fixed order will sooner or later have a hyphen mistyped if it lives in the body. Wrapped as a script, the body keeps one line. Conversely, if it is just invoking an existing tool with two or three flags, write the command in the body directly — there is no need to create a scripts/ directory for it.

The flip side of the third criterion needs saying too: several ecosystems already have run-without-installing mechanisms, such as npx on the Node side and uvx and pipx on the Python side. One-off commands like these can go straight in the body, but always pin the version:

BashBash
npx eslint@9.0.0 --fix .
uvx ruff@0.8.0 check .

Without a pinned version, your skill's behavior will change on the morning some upstream ships a release, and you will have no idea why. Likewise, if a script has environment requirements, put them in the frontmatter's compatibility field — "requires git, docker, jq, and network access," say.

The bar for writing a script is a little higher than most people assume: it is a long-lived asset that must be maintained, kept in step with the templates, and legible to someone else. So when none of the three criteria hits, write the body honestly.

Sign in and link WeChat to read

Sign in, then link your WeChat mini program account on the account page. Linked accounts share one free article per day. Unlock additional articles with rewarded videos in the mini program.

Mini program QR code

Scan in WeChat to open Dayward AI. Open the same course and chapter, choose the rewarded video, then refresh this page after completion.

Interview questions

  • Which logic belongs in a skill's scripts directory and which belongs in the SKILL.md body?什么逻辑该写成脚本放进 skill 的 scripts 目录,什么该留在 SKILL.md 正文里?
    Common in ChinaCommon overseasBasic#agent-skills#scripts

    🔒 Unlock this chapter to see the answer keys.

  • How does designing a command-line script for an agent differ from designing one for a human?给 Agent 用的命令行脚本,接口设计上和给人用的有什么不同?
    Common in ChinaCommon overseasIntermediate#agent-skills#scripts#cli-design

    🔒 Unlock this chapter to see the answer keys.

  • What security risks come with bundling scripts in a skill, how would you contain them, and why should document tasks follow plan, validate, then execute?skill 里带脚本会带来哪些安全风险?你会怎么限制它?另外,为什么文档处理这类任务要先规划再校验后执行?
    Common in ChinaCommon overseasDeep dive#agent-skills#security#workflow-design

    🔒 Unlock this chapter to see the answer keys.

Comments