Agent Skill
Apply AFDATA at structured-data boundaries. Field names carry units, formats, and sensitivity so an agent can interpret values without extra prose; paths handed to a destructive command carry what they are supposed to be, and are checked before anything is removed.
The afdata CLI
The shell rules and checks below run through the afdata CLI. If afdata is
not on PATH, install it before falling back to anything else:
brew install agentfirstkit/tap/afdata # macOS / Linux
scoop bucket add agentfirstkit https://github.com/agentfirstkit/scoop-bucket && scoop install afdata # Windows
cargo install agent-first-data # anywhere with a Rust toolchain
Prebuilt archives are at https://github.com/agentfirstkit/agent-first-data/releases.
If none of these can run, say so instead of silently substituting jq,
python3 -c, or a bare rm -rf.
Start with the smallest source
Read only the route needed for the task:
| Task | Read |
|---|---|
| Name or review fields, configs, logs, database columns, wire/API data, redaction, or rendering | naming-output.md, then use registry.json for exact suffix metadata |
| Build or review protocol events, CLI output, logging, version/help behavior, value-source declarations, or stream routing | cli-protocol.md and protocol-v1.schema.json |
| Build or validate a closed-world CLI or structured help | cli-protocol.md, cli-spec-v1.schema.json, and cli-help-v2.schema.json |
| Read or safely mutate JSON/TOML/YAML/dotenv/INI or Markdown frontmatter, read a property list (plist), or read a Markdown file’s heading sections | documents.md |
| Author an AFDATA-style Bash 3.2+ executable | bash.md |
The formal contract is spec/agent-first-data.md in a repository checkout,
published at https://agentfirstkit.com/agent-first-data/docs/specification.
Use it only when changing the contract or resolving an ambiguity. The JSON
files above are byte-identical copies of spec/registry.json,
spec/protocol-v1.schema.json, spec/cli-spec-v1.schema.json, and
spec/cli-help-v2.schema.json, so they are exact offline. The focused Markdown
references are the offline equivalents of the prose. For a command’s exact
shapes, run afdata <command> --help.
If a README or example conflicts with the formal spec or schema, follow the formal source and report the discrepancy. Do not invent suffix meanings, protocol fields, or help fields.
Core decisions
- Add a registered suffix when a number’s unit, a string’s format, or a value’s sensitivity is otherwise ambiguous.
- Name secret values or subtrees
_secret; render them as***. - Treat
_secretas a structured-output guarantee only. Keep live secrets out of argv; useredact_argvbefore recording an invocation. - Name whole URL values
_url; scrub userinfo passwords and explicitly secret-named query parameters. - Configure exact
url_namesfor legacy URL fields; collection values recurse without guessing unrelated field names. - Do not scan arbitrary prose for secrets. Rename the field or configure an
exact secret name at the serialization boundary; use the explicit
redact_urls_in_texthelper only for complete scheme URLs embedded in prose. - Keep JSON and YAML schema-preserving. Use plain output only as the lossy, human-readable form.
- For closed-world CLIs, register every legal invocation shape.
- When using Rust sourced arguments, declare the accepted sources, classify
them before domain I/O, and read credentials through
read_secret(). - Use one protocol envelope shape across CLI, HTTP, MCP, SSE, and logs when claiming AFDATA protocol compatibility.
- Before renaming a public API, wire, database, or persistent field, explain the compatibility impact and obtain approval.
Shell decisions
These apply to a one-off command as much as to a script.
- Before deleting a path built from a variable, name what it must be and let
the guard check it:
afdata_remove TYPE VALUEin a script that loads the Bash kit; otherwise assign first and delete the checked path,target="$(afdata guard tmp_path "$dir")" && rm -rf -- "$target". Never put$(afdata guard ...)inside thermoperand itself; its failure is lost. - Move a person’s own files with
afdata_trash; it refuses rather than deletes when the move cannot be undone. Build output and scratch useafdata_remove. - Read structured files with
afdata value,get,keys, orvalues, and edit them withafdata set; neverjq,grep,sed, orpython3 -c. - When a script parses arguments, emits logs or results, or runs child processes, use the Bash kit instead of hand-written option parsing or ad hoc JSON.
Implementation workflow
- Identify the serialization boundary and whether the output is a finite result or an ordered event stream.
- Inspect existing public and persistent names before changing them.
- Use the runtime library instead of reimplementing suffix formatting, redaction, event envelopes, or CLI errors.
- Redact before serialization. For HTTP/MCP/SSE paths that bypass
render, callredacted_value; useredact_url_secretsfor one URL orredact_urls_in_textfor scheme URLs already embedded in prose. - For a Rust closed-world CLI, build one
CliSpec, bind handlers byaction_id, and read arguments through typedResolvedInvocationaccessors. Go, Python, and TypeScript provide emitters and readers while the application manages argv and lifecycle. Bash has its own argument kit. Use the protocol schema when implementing compatible event output. - Validate examples and emitted data with the checks below.
Runtime API names follow native casing. For imports and signatures, consult only
the relevant language guide: rust/README.md, go/README.md,
python/README.md, or typescript/README.md in a checkout, published under
https://agentfirstkit.com/agent-first-data/docs/ as rust, go, python, and
typescript.
CLI checks
Validate with afdata:
afdata lint payload.json
afdata lint --schema schema.json
afdata lint --violations-only payload.json
afdata validate event.json --per-event --strict
afdata validate events.jsonl --strict
afdata render payload.json --output yaml
afdata skill validate skills/example-skill
- Run
linton serialized data andlint --schemaon JSON Schema or API declarations. A completed report containsviolationsandadvisories. Suggestions alone produceok: trueand exit 0.--violations-onlyskips suggestions. - Run
validate --per-eventfor independent events andvalidatefor a finite stream. Add--strictto either command to require the strict profile. - Use
renderto apply AFDATA redaction and formatting. skill validatechecks metadata and directory naming, not the Markdown body’s instructions, links, or bundled references. Review those and verify an actual install when changing a skill’s resources.- If a required check cannot run, state that explicitly.
Review exit criteria
- Ambiguous units and strict string formats use registered suffixes and valid JSON types.
- Secrets redact on every output path, including defaults shown in help.
- JSON/YAML retain original keys and scalar types.
- Protocol events use
kindand a same-named payload. Every error has non-emptycodeandmessage. Strict events also require object-valuedtraceand strict errors require booleanretryable. - Finite output and event streams use the correct channel policy.
- In a closed-world CLI, every application argument belongs to a combination, combinations are disjoint, and unregistered mixtures fail before domain I/O.
- Declared value-source sets are non-empty and unambiguous, malformed or unaccepted sources fail before I/O, and credential reads return a redacting type.
- Help-v2 output validates against its schema, describes each registered shape, and keeps version values and long-form Markdown out.
- Config/document edits preserve unrelated source text and avoid exposing secrets in argv.
- No compatibility-sensitive name changed without explicit approval.
Reporting Problems
If afdata itself is wrong — a crash, an internal error, or behavior that contradicts its docs, not a configuration or credential problem — or the person wants a missing feature, offer to open an issue at https://github.com/agentfirstkit/agent-first-data/issues. Check for duplicates first. Include afdata --version, the command, error.code, and expected versus actual, with placeholder data only: never the person’s data, paths, or secrets. File it with gh issue create only after the person approves the draft.