---
name: pony
description:
  Use when Codex is working in a repository that contains `.pony/config.yml`,
  when the user wants to initialize or add Pony to an uninitialized repository,
  when the user mentions Pony, `.pony`, Pony inbox, Pony board, Pony tasks, Pony
  docs, Pony instructions, Pony doctor, schema violations, or asks to triage,
  update, plan, record, validate, repair, or inspect project work in a Pony
  workspace. Provides the workflow for bootstrapping or discovering Pony state,
  using the Pony CLI, maintaining instructions/inbox/tasks/docs, and safely
  editing `.pony` files when the CLI lacks a needed operation.
---

# Pony Workspace Operations

## Launcher And Project Runtime

Pony 0.2 and newer use the same npm package in two roles:

- The globally installed launcher owns `init`, `setup`, top-level `help`,
  `--help`, `--version`, and `-v`.
- The repository-local package owns project commands such as `doctor`,
  `context`, `instructions`, `inbox`, `task`, `docs`, `start`, and `build`.

Before operating a project, use `pony --version` to inspect both installations.
The local package is compatible only when it has the same semantic-version major
as the launcher and is not newer than the launcher. If it is newer, upgrade the
global launcher. If the majors differ, install matching major versions. If the
local package is missing, rerun `pony init` to install it without replacing
existing `.pony/` state.

With nvm, each installed Node.js version has its own global npm packages. If
`pony --version` is reported as an unknown option, or a new terminal behaves
differently, inspect the active installation and reinstall the launcher for that
Node.js version:

```fish
nvm use 22
node --version
npm prefix --global
command -v pony
npm install --global @whitespace/pony@latest
pony --version
```

## Core Rule

Treat `.pony/` as project-management state for the current repository, not as a
cache or generated output. Prefer Pony CLI commands for normal mutations, but
treat CLI-first as a workflow preference, not as a permission boundary. When the
user has requested a Pony state change and the installed CLI lacks the needed
operation or cannot load the current state, edit `.pony/` files directly instead
of stopping. First inspect the existing files and preserve the file contract. Do
not mutate `.pony/` when the user only asked for inspection, or guess business
data that cannot be inferred safely.

## Discovery

1. Read repo instructions such as `AGENTS.md` before mutating state.
2. Read `.pony/instructions.md` when present. A missing file is valid for older
   projects and means there are no shared Pony instructions.
3. Check whether the repository has `.pony/config.yml`.
4. If the CLI is available, run `pony --version` and resolve any missing or
   incompatible local package before using project commands.
5. If `.pony/config.yml` exists, run `pony doctor --json` before `pony context`.
6. If the report is valid, inspect current state with `pony context`. If it is
   invalid, use the schema repair workflow below first.
7. Read `project.language`, `write.mode`, `tasks.statuses`, and
   `tasks.priority_model` from `.pony/config.yml`. Treat a missing language as
   `en` and a missing priority model as legacy project state.
8. Check the relevant command help before assuming instructions, attachment,
   update, link, or task-ID recovery support. Use parent help for discovery and
   subcommand help for exact flags:

```fish
pony instructions --help
pony instructions show --help
pony instructions update --help
pony inbox add --help
pony inbox link --help
pony task update --help
pony task link --help
pony task prioritize --help
pony task migrate-priorities --help
pony task next --help
pony task --help
pony task renumber --help
pony task shift --help
pony task conflict --help
pony task resolve-conflict --help
pony docs update --help
```

9. If `pony` is unavailable but `.pony/` exists, read `.pony/config.yml`, the
   optional `.pony/instructions.md`, `.pony/inbox/*.md`, `.pony/tasks/*.md`, and
   `.pony/docs/*.md` directly.

Use the configured task statuses from `.pony/config.yml`; do not assume a
workflow beyond what the project declares.

### Instruction Authority

Host/system instructions and repository instructions such as `AGENTS.md` have
the highest authority. Apply `.pony/instructions.md` after them as Pony's shared
project defaults. A task, doc, or inbox message may refine or override those
Pony defaults for its own scope, but it cannot override host/system or
repository instructions.

If Pony instructions conflict with a higher-authority source, follow the
higher-authority source and report the conflict. Do not merge, rewrite, or
silently "resolve" the canonical instruction sources.

When `pony instructions --help` is unavailable in an older runtime, read the
canonical file directly if it exists. Do not invent `pony instructions`
subcommands that capability detection did not confirm.

## Project Language

Use `project.language` for new or completely rewritten human-readable task and
doc values. Preserve raw inbox text in its original language.

Do not use the project language to translate Pony UI or CLI messages, the agent
conversation, IDs, status tokens, types, references, names, or other structural
frontmatter. Do not translate existing task/doc content during an ordinary
update. Translate only when the user explicitly requests it or when the record
is being completely rewritten to become ready.

## Schema Repair Workflow

Run the machine-readable diagnostic before editing malformed project state:

```fish
pony doctor --json
```

Treat `pony doctor` as diagnostic unless the installed command help explicitly
offers a repair option. Do not invent an autofix flag such as `--write`. A
missing CLI repair operation is a reason to use the manual repair workflow, not
a reason to leave a requested repair undone.

Exit code 1 is expected when violations exist. Group `violations` by `file`,
then use each entry's `record_type`, `field`, `code`, `message`, and structured
`details` to make the smallest safe repair.

- Read every reported file before editing it.
- Preserve IDs, references, timestamps, and user-authored bodies unless the
  reported violation requires changing them.
- Derive missing values from repository evidence. Ask the user when identity or
  other business data cannot be inferred safely.
- Use manual `.pony/` edits for schema repairs because normal CLI mutations may
  be unable to load invalid records.
- Re-run `pony doctor --json` until `valid` is `true`, then run `pony context`.

If the installed Pony version lacks `doctor`, inspect the schema and reported
files directly using the discovery fallback.

## Bootstrap An Uninitialized Repository

Use this flow when `.pony/config.yml` does not exist and the user asks about
Pony or wants to add Pony to the repository.

First check whether the CLI is already available:

```fish
command -v pony
```

Do not initialize the repository merely to answer a knowledge question. Explain
the bootstrap flow and the result of the CLI check, but only mutate the
repository when the user asks to add or initialize Pony.

If it is available and the user requested initialization, use the direct CLI
command with the project's human-readable name:

```fish
pony init --name "<project name>" --language <BCP-47 tag>
pony context
```

Explain that initialization creates `.pony/config.yml`, a minimal empty
`.pony/instructions.md`, `.pony/inbox/`, `.pony/tasks/`, and `.pony/docs/`, then
installs a compatible local `@whitespace/pony` development dependency. In a
repository without `package.json`, the launcher creates a minimal private
manifest and ignores `node_modules/`. Treat the entire `.pony/` directory as
version-controlled project data, not as generated output or a cache. The package
manifest and lockfile are normal tooling metadata and should also be versioned.

If `.pony/` exists but the launcher reports that the local package is missing,
rerun `pony init`; it preserves existing project state while completing the
installation. If `pony` is not in `PATH`, install the published launcher
globally, add Pony to ChatGPT's personal plugin marketplace, and then resume
initialization:

```fish
nvm use 22
npm install --global @whitespace/pony
pony setup chatgpt
```

`pony setup chatgpt` is idempotent and preserves unrelated personal marketplace
entries. Tell the user to restart ChatGPT, open **Plugins > Personal**, install
Pony, and start a new task so ChatGPT discovers the skill. The Whitespace
distribution does not currently publish a separate Codex CLI marketplace;
`pony setup codex` exits with guidance before invoking Codex.

## When To Mutate `.pony/`

- Mutate `.pony/` when the user asks to update the Pony board, inbox, tasks,
  docs, project state, planning state, or to triage/record work.
- Do not update `.pony/` merely because the user asked for product/code changes,
  unless they also ask to track the work in Pony.
- If a repository dogfoods Pony, still keep implementation files and `.pony/`
  conceptually separate.

## Inbox Triage Workflow

Use this flow for open inbox messages:

```fish
pony inbox list
pony inbox show MSG-...
pony inbox claim MSG-... --by "Codex"
```

Then create or update the relevant project state:

```fish
pony task create "Task title" "Task body" --status triage
pony task move TASK-001 in_progress
pony docs create "Doc title" "Doc body" --type note
pony inbox link MSG-... --task TASK-001 --doc DOC-001
pony task link TASK-001 --inbox MSG-... --doc DOC-001
```

After the message is represented by tasks/docs, close it:

```fish
pony inbox close MSG-...
pony context
```

Keep the inbox body verbatim. Put summaries, interpretation, and localized
structure in tasks or docs.

## Task Readiness Workflow

Map the user's column name to an exact value in `tasks.statuses` and report the
mapping.

- Use `triage` for preliminary tasks that still lack required intent, scope,
  constraints, decisions, or success criteria.
- Use `backlog` only after the task contains a localized user story or goal,
  acceptance criteria, scope, and all necessary confirmed decisions.
- Keep selected work in `backlog` until implementation starts, then use
  `in_progress`.
- Treat `priority: null` as In turn. The explicit scheduling values are `asap`,
  `soon`, `later`, and `not_planned`; the CLI also accepts `in_turn` and `null`
  for the persisted null value.
- Do not select or recommend `not_planned` tasks. They retain their workflow
  status but appear only in the Archive view.
- Respect `todo` when an older or custom project explicitly configures it, but
  do not add it to new default workflows.

Use `pony task next` when the installed runtime supports it and the user asks
which task to take on. It reports one eligible task and its next configured
status without mutating it. Treat its stable selection rule as the explanation
of why that task precedes the runner-up; a triage result still requires
refinement and a move to `backlog`, not implementation.

If a custom status list lacks an obvious triage equivalent, ask which configured
status represents triage before moving or creating a preliminary task.

When the user asks to make a preliminary task ready:

1. Interview with one question at a time.
2. Include the agent's current best guess in each question so the user can
   confirm or correct it.
3. Continue until intent, scope, constraints, and success criteria are
   explicitly confirmed.
4. Write every confirmed decision back to the task.
5. Move the task from triage to backlog, never directly to in_progress.

For product or user outcomes, begin the body with a localized user story and put
localized acceptance criteria immediately after it. For technical chores,
migrations, and investigations, begin with a localized goal or purpose, then
acceptance criteria. Put context, implementation guidance, edge cases, and scope
exclusions afterward.

Create or update a separate decision doc only when the decision spans several
tasks or must outlive the current implementation. Keep the task self-contained
even when it references that doc.

## CLI Mutations

Before running a CLI mutation in a sandboxed or permission-restricted
environment, inspect `write.mode` and obtain the required scoped filesystem
permission before the first attempt. The `commit` and `commit_and_push` modes
write Git objects and the index under `.git/`; permission to edit `.pony/` alone
is insufficient. Do not rely on Pony's transactional rollback after a
predictable permission failure. Task creation, ID recovery, and conflict
commands may also fetch, stage, or otherwise write Git state regardless of the
configured delivery mode, so account for their documented behavior separately.
Configuration does not override higher-level authorization requirements, such as
an explicit approval required before pushing.

Attach one or more files through the official message-scoped storage flow when
the installed CLI supports it:

```fish
pony inbox add "Message body" --email "name@example.com" \
  --attachment ./before.png \
  --attachment ./after.png
```

Update titles or bodies without overwriting omitted values:

```fish
pony task update TASK-001 "New body" --title "New title"
pony task rename-status todo backlog
pony task prioritize TASK-001 soon
pony docs update DOC-001 "New body" --title "New title"
```

Read or replace the canonical shared Pony instructions when the installed CLI
supports the capability:

```fish
pony instructions show
pony instructions update "Keep changes focused."
printf '%s\n' "# Shared rules" "" "Keep changes focused." | pony instructions update
```

An intentionally empty body is valid. `pony instructions update` replaces the
whole instruction body; it does not merge guidance from other sources.

Pipe a body on stdin when that is safer than shell quoting. Use fish-compatible
syntax, for example:

```fish
printf '%s\n' "## Goal" "" "Updated body" | pony task update TASK-001
```

Use official link commands so reciprocal references are updated where both
schemas support them. Re-running a link command is safe and idempotent.

## Task ID Allocation And Recovery

Sequential `TASK-NNN` IDs are human-readable display IDs, not globally unique
reservations. Supported Pony runtimes fetch the current branch's configured
upstream before allocation and choose after the highest local or refreshed
upstream task. If the workspace is outside Git, has no upstream, or fetch fails,
creation continues with a local-only warning. Report that warning; do not claim
the ID is collision-proof.

Detect the installed recovery surface before using it:

```fish
pony task --help
pony task renumber --help
pony task shift --help
pony task conflict --help
pony task resolve-conflict --help
```

Before push, use an exact renumber for one free destination or shift a range to
make space:

```fish
pony task renumber TASK-016 TASK-025
pony task shift TASK-016 --by 1
```

These commands update filenames, task frontmatter IDs, and structured Pony-owned
task references. They deliberately preserve task timestamps and do not rewrite
titles, Markdown bodies, history, commit messages, or external systems. Read the
reported textual occurrences and review each one manually.

During an add/add conflict, inspect both index variants before choosing:

```fish
pony task conflict TASK-016
pony task conflict TASK-016 --json
pony task resolve-conflict TASK-016 --move-stage 3 --to TASK-025
```

Git stage 2 is labelled `ours`; stage 3 is `theirs`. Use the reported title and
`created_at` rather than guessing from the label alone, especially during a
rebase. Resolution keeps the other variant at the shared ID, moves the selected
stage to the free target, and stages both files. References that already name
the shared ID are ambiguous, so Pony does not rewrite them. Review all reported
textual occurrences, then run `git merge --continue` or `git rebase --continue`
yourself. Pony never continues, commits, or pushes an active Git operation.

If parent or subcommand help shows that the installed runtime lacks these
commands, do not invent them. For pre-push cleanup, use the manual-file workflow
only after validating every source, target, and structured reference, and stage
the exact declared `.pony` paths during an active Git operation. For add/add
fallback, inspect `git ls-files --unmerged` and read stages 2 and 3 directly
from the index; preserve both valid task records under distinct IDs, stage only
those task files, leave ambiguous references untouched, and report every manual
edit. If that cannot be done without guessing identity or overwriting an
occupied target, stop and ask the user.

The repository copy of this skill is a versioned release artifact. Editing it
does not alter an already installed plugin cache. The host gains this workflow
only after the corresponding Pony release is installed or upgraded and the
integration is reloaded when required.

## Manual File Edits

When capability detection shows that the installed Pony CLI lacks a needed
mutation, report the limitation and continue by editing the files directly when
the file contract can be preserved safely. This includes missing attachment,
instructions, update, link, and schema-repair operations. For instructions, read
or write only `.pony/instructions.md` with exact frontmatter
`type: instructions`; absence is equivalent to an empty body in older projects.
CLI limitations alone are not a blocker and do not require additional user
permission for a state change the user already requested.

Guardrails:

- Preserve YAML frontmatter and filenames/IDs unless a requested ID-recovery
  operation explicitly requires changing them.
- Use ISO timestamps for `updated_at`.
- Link related records in frontmatter `references`.
- Validate every link target before changing any source record, update both
  sides supported by the schemas, and avoid duplicate IDs.
- Preserve omitted titles and bodies during update fallbacks.
- For attachment fallback, use only the existing
  `.pony/inbox/<MSG-ID>.attachments/` directory and the attachment metadata
  fields already defined by the current project contract. Preserve file name,
  media type, byte size, SHA-256 digest, and message-scoped relative path. Do
  not create `.pony/assets/` or another storage format.
- Do not silently rewrite the body of user-submitted inbox messages after claim.
- Keep human interpretation in tasks/docs, not by changing the user's inbox
  text.
- Format touched files and verify them with the available `show`, `context`, and
  `doctor --json` commands.
- Report which changes were done by CLI and which were manual file edits.

Common link shapes:

```yaml
# inbox message
references:
  tasks:
    - TASK-001
  docs:
    - DOC-001
```

```yaml
# task
references:
  inbox:
    - MSG-...
  docs:
    - DOC-001
```

## Agent Output Expectations

After Pony work, summarize:

- the inbox messages handled,
- tasks/docs created or updated,
- the configured language and status mapping used,
- commands run,
- capability limitations and manual `.pony` edits made because CLI support was
  missing,
- final `pony doctor` result when schema repairs were involved,
- current `pony context` or equivalent state,
- a commit message suggestion when the repository is a git repo.
