shellkitshellkit
Guide
API reference
Examples
Changelog
Releases
llms.txt
GitHub
  • 简体中文
  • English
Guide
API reference
Examples
Changelog
Releases
llms.txt
GitHub
  • 简体中文
  • English
  • Getting started

    • Guide
    • Install and upgrade
    • Thirty seconds
  • Core concepts

    • Five hard rules
    • Bash 3.2 compatibility
    • Module map
    • POSIX subset
  • Common tasks

    • Cookbook
    • CLI framework
    • Machine-readable output
    • Security boundaries
    • Internationalisation
    • Testing and gates
    • Working with AI
  • Going further

    • Example projects
    • Man pages
    • Migration guide
    • Compatibility policy
    • Releasing
    • Contributing
    • Changelog
  • Troubleshooting

    • Troubleshooting
    • FAQ

Working with AI

These constraints were written for machines in the first place: banned syntax, task-to-module mapping, and a pre-delivery self-check. They are all decidable rules, not "please keep things tidy".

Three artefacts, one source

FileAudience
AGENTS.md (repository root)AI writing code in this repository
templates/AGENTS.mdevery project generated by shellkit new carries a copy
skills/shellkit/installed as a skill into an AI client (entry point + references/ details)

All three are assembled from docs/ai/contract.md, so one edit updates all three. Hand-maintaining three copies guarantees drift, and drift means the AI generates code against an expired rule.

Install it into an AI client

The skill is a progressively disclosed package: SKILL.md is the entry point (when to use it, how to pull the library in, three hard facts, the task-to-module table), and the details live in references/ (the full API, the scenario cookbook, Bash 3.2 compatibility, the CLI reference). The AI reads the entry point first and only opens a reference when it needs one, so the main context stays small.

shellkit skill list                       # which clients are known, and whether the skill is installed
shellkit skill install                    # install into every detected client
shellkit skill install --client claude    # install into one client
shellkit skill install --dir ~/.my/skills # a client that is not in the table: pick the directory yourself
shellkit skill uninstall --client claude

The client directories are conventions of each vendor (Claude Code uses ~/.claude/skills/, MCode uses ~/.minimax/skills/, Codex uses ~/.codex/skills/, ...), so:

  • the installer only writes into a client root that already exists -- it never creates a directory for a client you do not have;
  • if the path is wrong, pass --dir;
  • if you are still unsure, shellkit skill print dumps the entry file for a manual copy.

If the target is already a symlink, the install is skipped with an error (exit code 3): writing through a symlink lands somewhere else, and an exit code of 0 would leave the person who ran it none the wiser.

Without the CLI there is still a way: every release ships the skill package on its own (releases/latest/download/shellkit-skill-<version>.tar.gz); unpack it into <client skills dir>/shellkit/.

Why it works

When an AI writes Bash, two failure modes dominate:

  1. Using syntax that only exists in 5.x (declare -A, ${v^^}, mapfile), which crashes on the bash macOS ships.
  2. Inventing function names (conf_require, log_success), which blow up at run time with an error message nobody can decode.

The "do not write / write this / what 3.2 does" table in AGENTS.md addresses the first. docs/REFERENCE.md, generated from source comments, addresses the second -- and because it is also the source of truth for check-docs, "in the docs but not in the code" is impossible.

A prompt you can paste

Write deploy.sh using shellkit:
 - logging via log_info / log_ok / log_warn / log_error, all to stderr
 - read config with conf_init + conf_get_any; write it with conf_set (idempotent)
 - fail via die / require_cmd; pick exit codes from 0/1/2/3/4/5, never a blanket exit 1
 - download with net_download URL DEST sha256; wait for ports with net_wait_port
 - single instance via lock_acquire
 - run commands with run (stops on failure); inside an if, use run --no-die
 - banned: declare -A / local -n / ${v^^} / mapfile / [[ -v ]]
 - iterate possibly empty arrays as ${arr[@]+"${arr[@]}"}
 - before delivering, run bash -n and shellcheck -S warning -x and paste the real output

The last line is the important one: make it paste output, not claim "this should work".

Pre-delivery self-check

bash -n the-scripts-you-changed.sh
shellcheck -S warning -x the-scripts-you-changed.sh
make test

Three criteria must hold together: exit code 0, no FAIL lines, you read the output yourself. Exit code alone misses "the command never ran"; output alone misses silent failure.

What not to let an AI do

  • Do not let it "rewrite the script while it is at it". The target is the one change you asked for.
  • Do not accept "this should work". Demand the actual command and the actual output.
  • Do not let it invent function names: when unsure it should check the API reference, and a name that is not there does not exist.
Last updated: 11/22/26, 7:50 PM
Prev
Testing and gates
给 AI 直读:llms.txt 一个文件读完整个站点的地图