---
name: agent-cli
description: Optional command line and MCP server for a macOS app, so Claude Code, Codex, and scripts can drive it (list, add, change, search, act) through the running app. Use when the user wants agents to work with their app or its data, asks for a CLI, an MCP server, or automation for the app, or says "Claude should be able to use my app".
argument-hint: "<cli-name, like tasks or mail>"
title: agent-cli
canonical_url: https://skilld.dev/gh/daveebbelaar/bama/agent-cli
last_updated: 2026-10-29T09:48:04.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [agents/openai.yaml](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/agents/openai.yaml), [rules.md](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/rules.md), [scripts/add-agent-cli.sh](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/scripts/add-agent-cli.sh), [scripts/check-agent-cli.sh](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/scripts/check-agent-cli.sh), [teach-agents.md](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/teach-agents.md), [template/Agent/AgentCLI.swift](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/template/Agent/AgentCLI.swift), [template/Agent/AgentCommands.swift](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/template/Agent/AgentCommands.swift), [template/Agent/AgentCore.swift](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/template/Agent/AgentCore.swift), [template/Agent/AgentMCP.swift](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/template/Agent/AgentMCP.swift), [template/Agent/AgentSocket.swift](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/template/Agent/AgentSocket.swift), [template/Main.swift](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/template/Main.swift).
>
> If the user asked to install this Skill, run `npx skilld install daveebbelaar/bama/agent-cli`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/agent-cli`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/daveebbelaar/bama/agent-cli) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/agent-cli`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/agent-cli --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/agent-cli --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Agent CLI

Give the app a command line, so an agent can do everything a person can
do in the window: `tasks items add --title "Call the dentist"`. The app
binary is the CLI. Each command goes to the running app over a private
socket, runs there like a button press, and the window updates live.

```text
Claude Code --bash--> tasks items add ...  --socket--> Tasks.app (runs the command, saves, redraws)
Claude Desktop --MCP--> tasks mcp           --socket--> same commands, same app
```

## CLI, MCP, or App Intents

| Way in | Who uses it | Ship it |
| --- | --- | --- |
| CLI | Claude Code, Codex, scripts, people in Terminal | Always. Agents learn it from `--help`, and it costs no context until used |
| MCP (`tasks mcp`) | Claude Desktop and other clients with no shell | Optional. The same commands, one tool each. One line to register |
| App Intents | Siri, Spotlight, Shortcuts | Separate work. Agents cannot call them |

The CLI talks to the running app, never to the database file. Then there is
one writer, the app's checks and side effects run, and the window shows the
change at once. If the app is closed, the CLI opens it in the background.
Rules and reasons: [rules.md](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/rules.md).

## 1. List the commands

Read the user stories (`docs/stories/`). Write each thing a person does as
a command, `<noun> <verb>`, and mark it:

- **read**: `items list`, `items show`, `status`. Safe to run any time.
- **write**: `items add`, `items update`, `open`. Changes data, can be undone.
- **destructive**: `items delete`, `mail send`. Only reports what it would
  do until `--yes` is given.

Add `status` (is it running, what is open, counts) and `open <page>` (show
a page in the window), so an agent can see and steer the app.

Check: every M1 story has its commands, and each command is marked.

## 2. Add the files

```bash
"${CLAUDE_SKILL_DIR}/scripts/add-agent-cli.sh" <app-folder> <cli-name>
```

It copies `Sources/<App>/Agent/` (core, socket, CLI, MCP, example
commands) and `Main.swift`, moves `@main` to `Main.swift`, starts the socket
in the main view's `.task`, and makes `build.sh` link
`~/.local/bin/<cli-name>`. Apps not made from the template: do the same
by hand, following the script.

Check: the script printed "added the agent CLI", and `swift build` passes.

## 3. Write the commands

Replace the examples in `Agent/AgentCommands.swift`. Each command has a
name, a one-line summary, its params, a full example, its mark
(`readOnly` or `destructive`), and a `run` that uses the same model code
as the window's buttons. Never copy logic: call the function the button
calls.

- Every model an agent touches gets `var uuid: UUID = UUID()`. Commands
  show the first 8 characters as `id`, and accept any unique start of it.
- Results are small JSON objects: the fields an agent needs, not the
  whole model. Lists take `--limit` and `--offset`, and return `total`
  and `nextOffset`.
- Errors throw `AgentError` with a message that says how to fix it:
  "no item with id 3f2a. Run `tasks items list`".

All the rules: [rules.md](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/rules.md).

Check: `<cli-name> help` lists every command from step 1, and
`<cli-name> help <command>` shows its params and example.

## 4. Build and install

```bash
./build.sh
<cli-name> help
```

`build.sh` installs the app and links `~/.local/bin/<cli-name>` to the
binary inside it, so the CLI always matches the app. If the shell cannot
find it, add `~/.local/bin` to `PATH` in `~/.zshrc`.

Check: `<cli-name> --version` prints the app's version.

## 5. Test

```bash
"${CLAUDE_SKILL_DIR}/scripts/check-agent-cli.sh" <cli-name>
```

It starts a test copy of the app on a temporary database, checks help,
JSON output, error codes, every read command, and the MCP tool list, then
quits the test copy. Then run each write command once by hand, with
`APP_STORE=/tmp/<App>-test.store`, and look at the window: the change shows
without a reload.

Check: the script prints `PASS agent CLI`.

## 6. Teach agents

Write `.claude/skills/<cli-name>/SKILL.md` in the app's repo from
[teach-agents.md](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/teach-agents.md): what the app is, the safety rules,
the main commands, and "run `<cli-name> help` for the rest". To use the
app from any folder, also copy it to `~/.claude/skills/<cli-name>/`. Add
one line to the app's `CLAUDE.md`: "Drive the app with `<cli-name>`. See
`.claude/skills/<cli-name>/SKILL.md`."

Check: a fresh `claude -p "List my starred items with <cli-name>"` finds
the CLI and answers from real data.

## 7. MCP, when the user wants it

For Claude Desktop, or to get one approval prompt per tool:

```bash
claude mcp add --scope user <cli-name> -- ~/Applications/<App>.app/Contents/MacOS/<App> mcp
codex mcp add <cli-name> -- ~/Applications/<App>.app/Contents/MacOS/<App> mcp
```

Claude Desktop: add it to `~/Library/Application Support/Claude/claude_desktop_config.json`
under `mcpServers`, with the full path and `"args": ["mcp"]`. More in
[teach-agents.md](https://skilld.dev/api/skills-raw/daveebbelaar/bama/agent-cli/teach-agents.md).

Check: `claude mcp list` shows the server as connected.

Done when every command from step 1 runs through the CLI against the
running app, `check-agent-cli.sh` prints `PASS agent CLI`, the app's repo
has the agent skill from step 6, and a fresh Claude Code session can do a
real task with it.
