Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ak Init?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ivan-ii-tech-digital-ak-init)
---
name: ak-init
description: Scaffold agent-kit configuration for a consumer project
disable-model-invocation: true
model: sonnet
---
# ak-init
Sets up the project side of agent-kit (the kit's `docs/setup.md` §5, §6 and §9) in the repository
you are in. Work from the project root (`git rev-parse --show-toplevel`). Add only; never delete,
reorder or rewrite anything already there. Run no `claude plugin` command yourself.
## 0. Required tools
Run `"${CLAUDE_PLUGIN_ROOT}/bin/ak-doctor" --tools` (only the required-tool lines, no network).
If any line is not `ok`, show those lines first, under the heading **Install before using
agent-kit**, with each line's install command. Hooks fail open without them, so the kit looks set up but
guards nothing (setup.md §1). Then go on: steps 1–4 need only Node.js (`ak-init-apply`
runs on it).
## 1. Ask
Before asking, run `"${CLAUDE_PLUGIN_ROOT}/bin/ak-init-apply" --print-branches` (it writes nothing): its
`development <branch|->` and `production <branch|->` lines are the branch proposal, read from `origin`
(`origin/HEAD`, else the remote's HEAD; production is a separate `main` or `master` on origin). Then build
the quality-gate proposal (below). Ask all in one `AskUserQuestion` call, the recommended answer first:
- **Bundles** (multi-select) beyond `ak-core`, which every project gets: `ak-team` (agent teams),
`ak-spec` (spec pipeline), `ak-startup` (business decisions; brings `ak-team`). None is a valid answer.
- **Branch strategy** (only when `.agent-kit/config.json` has no `branchStrategy`): recommended
`development = <development>` (work starts from it, PRs target it) and, when the production line is not
`-`, `production = <production>` (releases promote to it). Development `-` (no origin): ask which branch
work starts from, default the current branch. Without the key the kit takes `origin/HEAD`, else the first
`protectedBranches` name, else `main`.
- **Protected branches**: default the development and production branches from the line above (both, for
example `["develop", "main"]`), else `["main"]`; the user may name others.
- **Quality gates** (only when `.agent-kit/config.json` is absent or its `qualityGates.ci` is absent or
empty): the proposed `qualityGates.ci` list, shown whole in one JSON block before asking with the jobs not
mirrored under it; recommended: use it as shown; or none (`[]`).
- **stack.md** (only when `.agent-kit/stack.md` is absent): write the detected draft, or the empty
template. Before asking, build the draft (below) and show it whole in one code block, marked
`dry run: nothing written yet`.
- **Constitution** (only when `docs/constitution.md` is absent): create it from the kit template, the
project's binding rules that every agent loads through `CLAUDE.md`, or skip. Default: skip; never create
it without a yes.
### The quality-gate proposal
Read the CI config: `.github/workflows/*.yml` (jobs a `pull_request` event runs) and `.gitlab-ci.yml` with
its local `include:` files (jobs a merge request pipeline runs: no `rules`/`only`, or rules that match
`$CI_PIPELINE_SOURCE == "merge_request_event"`, or `only: merge_requests`). A job that checks the code and
runs on a developer machine becomes one gate, `{"name": "<job>", "run": "<its check commands>"}`: lint,
format check, type check, unit tests, a build. Keep its working folder (`cd coreApi && yarn lint`, from
`cd`, `working-directory:` or `defaults.run.working-directory`) and join its commands with `&&`; leave out
setup steps (checkout, cache, dependency install, tool setup actions). Not mirrored, each listed with a
reason: security-scan templates (`Security/SAST`, `Secret-Detection`, `Dependency-Scanning`, CodeQL),
deploy, release and publish jobs, and jobs that need CI variables or secrets (`$CI_*` beyond the pipeline
source, `secrets.*`, cloud credentials) or service containers. No CI config, or nothing local-runnable: the
proposal is `[]`. Guess nothing: every gate's command is in the CI file.
### The stack.md draft
Read what the repository already says; guess nothing. Sources: package manifests (`package.json`
with its `scripts` and `engines`, `pyproject.toml`, `requirements*.txt`, `go.mod`, `Cargo.toml`,
`Gemfile`, `composer.json`, `pom.xml`, `build.gradle*`, `*.csproj`), lockfiles (they name the
package manager), runtime pins (`.nvmrc`, `.node-version`, `.python-version`, `.tool-versions`),
CI config (`.github/workflows/*.yml`, `.gitlab-ci.yml`, `.circleci/config.yml`), `Makefile` and
`justfile` targets, and test-runner config files. Fill the template below: each line you fill ends
with `(detected: <file>)`, the file it came from. A path goes in backticks only when it exists
(`ak-doctor` warns on a path that matches nothing). A section with nothing detected keeps its
`_Replace:` hint. Under `## Verification`, write the one-test-by-name command only from the detected
runner's own filter (for example vitest or jest `-t "<name>"`, pytest `-k "<name>"`, go test
`-run '<name>'`); with no runner detected, keep the hint.
## 2. Project profile — create if absent
For each file below: if it exists, leave it untouched and report `skipped <path> (exists)`;
otherwise create it with the Write tool and report `created <path>`. Never write `.agent-kit/` files
through a shell heredoc, redirect or `mv`: with `HOOK_CONFIG_PROTECTION_STRICT=on` every shell write to
`.agent-kit/config.json` asks, which blocks a headless run; the Write and Edit tools pass for an
addition.
`.agent-kit/config.json` — `protectedBranches` = the answer from step 1 (default `["main"]`, shown
below); `qualityGates.ci` = the confirmed quality-gate proposal (`[]` when none). The branch strategy is
not written here: step 3 adds it. When the file exists and its `qualityGates.ci` is absent or empty, add
the confirmed gates with the Edit tool (report `merged .agent-kit/config.json qualityGates.ci`), nothing
else:
```json
{
"protectedBranches": ["main"],
"qualityGates": { "ci": [] }
}
```
Unless `.agent-kit/config.json` already has `guardrails.protectedConfigs`, suggest, without writing
it, a `guardrails.protectedConfigs` list (ak-guard's config-protection hook asks
before the agent edits these): the lint, format, type-check and test configs that exist at the root
(`.eslintrc*`, `eslint.config.*`, `.prettierrc*`, `.oxlintrc.json`, `tsconfig*.json`, `ruff.toml`,
`vitest.config.*`, …) and their ignore files (`.eslintignore`, `.prettierignore`, …): one line in an
ignore file switches a gate off as surely as an edited config. Show the JSON block to add by hand.
`.agent-kit/product.md`:
```markdown
# Product
_Replace: One paragraph: what the product is, who uses it, what must never break._
## Roles
_Replace: Each user role and what it may do._
## Plans
_Replace: Paid tiers or feature gates, if any; otherwise "None"._
## Locales
_Replace: Every supported locale; translation files live where stack.md says._
## Privacy rules
_Replace: Data that must never be logged, exposed or sent to third parties._
```
`.agent-kit/stack.md` (the draft from step 1 when the user chose it, else this template):
```markdown
# Stack
_Replace: Languages, frameworks, runtime versions, package manager._
## Code paths
_Replace: Path patterns for backend endpoints, types and data access; frontend pages, components, shared logic and types; translation files._
## Generated code
_Replace: Generated folders and the command that regenerates them; never hand-edited._
## UI library
_Replace: Component library, its docs URL or MCP server, the confirmation pattern for destructive actions, and the design-token file, if any._
## Verification
_Replace: One command per line, with its prerequisites: the full test run; ONE test by name (the `VALIDATE:` line of tasks.md uses it); format and lint one file; the check scripts. The full-run commands also go in qualityGates.ci._
```
`docs/constitution.md` (only on a yes in step 1): copy `${CLAUDE_PLUGIN_ROOT}/templates/constitution.md`
as it is; its first note tells the user what to fill in. Do it before step 3, so the import line is added.
## 2b. Forge
Run `ak-forge which` (ak-git's bin). Not on PATH → print `forge: not checked (ak-git not enabled)` and
go on. A `-` path means no `origin` remote: print `forge: none yet (no origin remote; the forge commands
need one)` and go on. Otherwise print `forge: <forge> (<host>)` from its `<forge> <host> <path>` line, then:
- `gitlab` with a host other than `gitlab.com`, and no `git.forge` in `.agent-kit/config.json` → add
`"git": {"forge": "gitlab"}` with the Edit tool (add only, never change other keys; into an existing
`git` object when there is one), and report `merged .agent-kit/config.json git.forge`.
- `github` with a host other than `github.com` (an SSH alias, GitHub Enterprise, or a host glab is not logged in
to) → print `forge: github (<host>) — if this is a self-hosted GitLab, add "git": {"forge": "gitlab",
"forgeHost": "<API host>"} to .agent-kit/config.json`.
- `none` (`git.forge` names neither forge) → print `forge: none — git.forge in .agent-kit/config.json is neither
"github" nor "gitlab"; set one of them`.
- Anything else needs no key.
## 3. Gitignore, `.claude/settings.json` and `CLAUDE.md`
Run, with the bundles from step 1 as a comma list inside the quotes (`--bundles ""` for none: a bare
`--bundles` is a usage error) and, when step 1 asked about the branch strategy, the confirmed branches
(`<development>` or `<development>,<production>`; leave `--branches` out otherwise):
```bash
"${CLAUDE_PLUGIN_ROOT}/bin/ak-init-apply" --bundles "<csv>" --branches <development>[,<production>]; echo "exit=$?"
```
It adds only, and prints one `created|skipped|merged|stopped <what>` line per step:
- `.gitignore` gets `.agent-kit/config.local.json` (per-machine overrides), `.agent-kit/state/` (the
`/ak-save` files), `.claude/worktrees/` (agent worktrees) and, with `ak-startup`, `docs/business/raw/`
appended when `git check-ignore` says they are not ignored yet; nothing else in the file changes.
- `.agent-kit/config.json` gets `branchStrategy` `{"development": ..., "production": ...}` from
`--branches`, only when the file has no `branchStrategy` key.
- `.claude/settings.json`: `enabledPlugins` true for `ak-core@agent-kit` and each bundle (`ak-spec` and
`ak-startup` bring `ak-team`), and with `ak-team` `env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: "1"`. An
absent file is created; a present one is deep-merged with the existing values winning. It never adds
`extraKnownMarketplaces` (setup.md §5: a committed `agent-kit` entry breaks every session start for
users whose registration differs).
- The attribution block `{"commit": "", "pr": "", "sessionUrl": false}` (always, without asking: no AI
attribution in a kit project, setup.md §5), replacing the key's old value, which the line shows.
- With `ak-spec`, the archive guard (agents read archived spec work only through `ak-archive show`,
setup.md §5): `Read(/docs/archive/**)` appended to `permissions.deny`, and `docs/archive/.ignore` (`*`).
- `CLAUDE.md` (created when absent) gets the context imports `@.agent-kit/product.md`,
`@.agent-kit/stack.md` and, when `docs/constitution.md` exists, `@docs/constitution.md`, under the
heading `## agent-kit context imports`, appended after the user's text. It also writes the memory-placement rule (the `rule` constant in `ak-init-apply`: `Memory: every memory written while working on
this project goes into this project's memory folder, …`) above the imports, shown as `+rule` in the out line, never twice (also
not when it is already there as a `- ` bullet or in `.claude/CLAUDE.md`). A line already in `CLAUDE.md` or
`.claude/CLAUDE.md` is never added again; a re-run puts a new line in the block. So the main session,
every subagent and every workflow agent load the project context, not only the team seats.
A `stopped` line with exit 2 means `.claude/settings.json` is not a valid JSON object: it was left
exactly as it is. Relay the line (fix it by hand, then re-run `/ak-init`) and go on to step 4; never
rewrite or "repair" the file. Relay a `merged` line's `kept false` part too: the project's value won,
and the user flips it by hand if they mean it.
## 4. Print the install commands
Print, for the user to run in a shell (user scope; never `--scope project`):
```bash
claude plugin marketplace add II-Tech-Ivan-Ivanov/agent-kit
claude plugin install ak-core@agent-kit
```
plus `claude plugin install <bundle>@agent-kit` for each chosen bundle (`ak-team`, `ak-spec`,
`ak-startup`). A machine that holds the kit checkout registers that folder instead
(setup.md §3). When `ak-team`, `ak-spec` or `ak-startup` is chosen, add: start Claude Code inside tmux
(setup.md §6).
## 5. Check
Run `"${CLAUDE_PLUGIN_ROOT}/bin/ak-doctor"; echo "exit=$?"` from the project root and relay every
line verbatim in one code block with the exit code. Lines about not-yet-installed bundles are
expected until the user runs step 4's commands; say so, then `/kit-doctor` re-checks.
Then point out the `auto-compact off`, `idle compaction off` (present only when the project sets
`context.warnTokens` or `context.stopTokens`) and `squash merge message` lines. A warn on the first two
holds the line to add to the user settings by hand: never write user settings. A warn
on the squash line holds a `gh api -X PATCH` fix that changes the GitHub repository's settings (its
default squash body lists the commits with `Co-authored-by` trailers): print it, never run it. No
squash line means no GitHub origin, no `gh` or offline. On a GitLab project point out the `glab present`,
`glab auth`, `gitlab project access` and `gitlab commit templates` lines the same way: a warn's fix
(a `glab auth login`, a template placeholder to remove in the project's settings) is printed, never run.
End with the list of created / skipped / merged files and remind the user to commit
`.agent-kit/` (without `config.local.json` and `state/`), `.claude/settings.json`, `.gitignore`, `CLAUDE.md`,
`docs/constitution.md` when it was created, and, with `ak-spec`, `docs/archive/.ignore`.