apply changedcli-sdks-libraries/cli/apply
Nearest release: v2.1.310, published 2 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+82added
Lines−1removed
From line
208
where the diff opens
First seen
4 Sep 2026
this site's first read of the page
Recorded edits11to this page, all time
The whole hunk
from line 208, old and new numbered
/
from line 208
208208
209209To point at a resource these files don't manage, write its ID (`agent_...`, `skill_...`) instead. Anything else, such as `{type: anthropic, skill_id: xlsx}`, is sent to the API as written. A skill reference can also be a GitHub URL of the form `https://github.com/<owner>/<repo>/tree/<branch>/<dir>`, for example a directory of Anthropic's open-source [skills repository](https://github.com/anthropics/skills): `ant apply` downloads and uploads that directory, pinned to the resolved commit until you run with `--upgrade` (set `GITHUB_TOKEN` for a private repository).
210210
211A path can also be a glob. Under `skills`, a glob references every skill it matches and skips anything else it matches, such as a README. Under an agent's `tools`, a path or glob names YAML or JSON files instead of resources: `ant apply` inserts each file's contents, one tool or a list of tools, into the list at that position. Put those files in a subdirectory such as `agents/tools/`, because `ant apply` refuses to insert a file that it would also read as an agent. A path or glob that matches nothing is an error.
212
213```markdown agents/reviewer.md
214---
215name: Code reviewer
216model: claude-opus-5-5
217tools:
218 - type: agent_toolset_20260401
219 - ./tools/*.json # the tools in these files are inserted here
220skills:
221 - ../skills/* # every skill under skills/
222---
223
224You review pull requests for correctness, security, and readability.
225```
226
227```json agents/tools/get_ci_status.json
228{
229 "type": "custom",
230 "name": "get_ci_status",
231 "description": "Get the CI status of a pull request",
232 "input_schema": {
233 "type": "object",
234 "properties": {
235 "pull_request": {
236 "type": "integer",
237 "description": "Pull request number"
238 }
239 },
240 "required": ["pull_request"]
241 }
242}
243```
244
211245### How ant apply infers a file's kind
212246
213247When `ant apply` walks a directory, it determines each file's kind from the first of these that matches:
from line 273
239273* Run one apply at a time, because nothing locks the lockfile.
240274* Authenticate with [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) rather than a stored API key, as an identity that reaches the organization and workspace recorded in `claude-lock.json`. `ant apply` refuses credentials that resolve to any other organization or workspace.
241275
242For a complete GitHub Actions workflow, see the [CI example in the CLI README](https://github.com/anthropics/anthropic-cli#in-ci).
276This GitHub Actions workflow does all of that except the pull request plan. It applies on every push to `main`:
277
278```yaml .github/workflows/ant-apply.yml
279name: ant apply
280on:
281 push:
282 branches: [main]
283 paths-ignore: [claude-lock.json] # so the lockfile commit doesn't start this workflow again
284
285jobs:
286 apply:
287 runs-on: ubuntu-latest
288 environment: agents-prod # protect it in GitHub: required reviewers, main only
289 concurrency: ant-apply # one apply at a time
290 permissions:
291 id-token: write # to request the identity token
292 contents: write # to push the lockfile commit
293 env:
294 ANTHROPIC_FEDERATION_RULE_ID: fdrl_...
295 ANTHROPIC_ORGANIZATION_ID: 00000000-0000-0000-0000-000000000000
296 ANTHROPIC_SERVICE_ACCOUNT_ID: svac_...
297 ANTHROPIC_IDENTITY_TOKEN_FILE: /tmp/gha-jwt
298 steps:
299 - uses: actions/checkout@v5
300 with:
301 ref: main # the tip of main, so a queued run has the previous run's lockfile commit
302 - uses: anthropics/setup-ant@v1 # installs the ant CLI
303 - name: Fetch GitHub OIDC token
304 run: |
305 curl -fsS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
306 "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://api.anthropic.com" \
307 | jq -r .value > "$ANTHROPIC_IDENTITY_TOKEN_FILE"
308 - name: Apply
309 run: ant apply --yes .
310 - name: Commit the lockfile
311 if: always() # a partial apply still records what it created
312 run: |
313 git diff --quiet claude-lock.json && exit 0 # nothing changed
314 git config user.name "github-actions[bot]"
315 git config user.email "github-actions[bot]@users.noreply.github.com"
316 git commit -am "Update claude-lock.json [skip ci]"
317 git pull --rebase # main can move during the apply, and a plain push would then be rejected
318 git push
319```
320
321Run the first `ant apply` on your machine and commit `claude-lock.json` before you turn the workflow on. The last step commits changes only to a lockfile that Git already tracks.
322
323To create the federation rule and service account that the `env` block names, see [Use WIF with GitHub Actions](https://platform.claude.com/docs/en/manage-claude/wif-providers/github-actions). Enable the rule for a single workspace, the one recorded in `claude-lock.json`, so that the token exchange doesn't need a workspace ID. Because the job names an environment, its identity token's `sub` claim is `repo:<owner>/<repo>:environment:agents-prod`, so that's the value the rule's `subject_prefix` must match.
243324
244325## Flags
245326
No line in this hunk matches that.