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:

TaskRead
Name or review fields, configs, logs, database columns, wire/API data, redaction, or renderingnaming-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 routingcli-protocol.md and protocol-v1.schema.json
Build or validate a closed-world CLI or structured helpcli-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 sectionsdocuments.md
Author an AFDATA-style Bash 3.2+ executablebash.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 _secret as a structured-output guarantee only. Keep live secrets out of argv; use redact_argv before recording an invocation.
  • Name whole URL values _url; scrub userinfo passwords and explicitly secret-named query parameters.
  • Configure exact url_names for 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_text helper 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 VALUE in 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 the rm operand 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 use afdata_remove.
  • Read structured files with afdata value, get, keys, or values, and edit them with afdata set; never jq, grep, sed, or python3 -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

  1. Identify the serialization boundary and whether the output is a finite result or an ordered event stream.
  2. Inspect existing public and persistent names before changing them.
  3. Use the runtime library instead of reimplementing suffix formatting, redaction, event envelopes, or CLI errors.
  4. Redact before serialization. For HTTP/MCP/SSE paths that bypass render, call redacted_value; use redact_url_secrets for one URL or redact_urls_in_text for scheme URLs already embedded in prose.
  5. For a Rust closed-world CLI, build one CliSpec, bind handlers by action_id, and read arguments through typed ResolvedInvocation accessors. 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.
  6. 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 lint on serialized data and lint --schema on JSON Schema or API declarations. A completed report contains violations and advisories. Suggestions alone produce ok: true and exit 0. --violations-only skips suggestions.
  • Run validate --per-event for independent events and validate for a finite stream. Add --strict to either command to require the strict profile.
  • Use render to apply AFDATA redaction and formatting.
  • skill validate checks 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 kind and a same-named payload. Every error has non-empty code and message. Strict events also require object-valued trace and strict errors require boolean retryable.
  • 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.