Skip to content

init command

FieldValue
Slugcmd-init
Statusimplemented
Last review2026-08-09

Summary

skli init initializes a skli project: detects the git repository root, collects project metadata (interactive or via flags), creates the ProjectManifest {gitRoot}/.skli/skli.json, and registers the path in the ProjectIndex.

User flows

Flow-01 — Init at git root (cwd = git root)

Persona: developer.
Preconditions: cwd is the root of a git repository; ProjectManifest missing.

StepActionExpected resultError
1skli initGit repository found; root = cwdNo git repository in the tree
2Collect name, description, versioning, tags (prompts or flags)Non-TTY without -y and missing fields
3Write {gitRoot}/.skli/skli.jsonEACCES
4Add gitRoot to ProjectIndex
5Success message; exit code 0

Flow-02 — Init from a subdirectory (parent git root)

Persona: developer.
Preconditions: cwd is not the git root; a git repository exists in a parent.

StepActionExpected resultError
1skli initParent git root discoveredNo git repository
2Ask permission to write the ProjectManifest at the repo rootUser decline → cancel
3With -yParent git confirmation accepted automatically
4Same continuation as Flow-01 (collect → write → ProjectIndex)

Flow-03 — Manifest already present

StepActionExpected resultError
1skli init without --force when .skli/skli.json existsNo writeClear error; exit code ≠ 0
2skli init --forceProject metadata overwritten; skills / rules / agents maps preserved if re-read OK, otherwise empty maps

Flow-04 — Non-interactive mode -y

StepActionExpected resultError
1skli init -yDefaults for missing fields; no prompts; parent git auto-confirmedNo git repository

Data model

ProjectManifest — see config-manifests. Fields written by init:

FieldDefault
$schemaCanonical ProjectManifest schema URL (see config-manifests)
namebasename of the git root
description""
versioningtag (VersioningMode)
tags[]
skills / rules / agents{} (or preserved if --force + re-read OK)

ProjectIndex: normalized absolute path of gitRoot added (no-op if already present).

CLI

skli init [options]

Options:
  --name <name>                          Project name
  --description <text>                   Description
  --versioning <tag|commit|branch|none>  Versioning mode (default: tag)
  --tag <tag>                            Project tag (repeatable)
  --tags <list>                          Comma-separated tags
  -y, --yes                              Defaults without prompt; confirm parent git
  -f, --force                            Allow overwrite if manifest present
  -h, --help                             Help

Exit codes: 0 success or cancel after parent-git decline; ≠ 0 error (no git, existing manifest without --force, validation, I/O).

Business rules

IdRule
BR-cmd-init-001Walk up from cwd until .git is found (file or directory).
BR-cmd-init-002No git repository in the tree → fatal error.
BR-cmd-init-003If cwd ≠ git root → ask confirmation to write at the repo root; -y accepts automatically.
BR-cmd-init-004Decline of parent-git confirmation → cancel without writing (exit code 0).
BR-cmd-init-005ProjectManifest = {gitRoot}/.skli/skli.json.
BR-cmd-init-006Manifest already present without --force → error; with --force → overwrite metadata, preserve package maps if readable.
BR-cmd-init-007Missing fields + TTY → interactive prompts (defaults in parentheses).
BR-cmd-init-008Missing fields + non-TTY without -y → error.
BR-cmd-init-009-y → defaults without prompt for missing fields.
BR-cmd-init-010versioning ∈ VersioningMode; default tag.
BR-cmd-init-011Tags: non-empty strings after trim; repeatable --tag and/or CSV --tags merged.
BR-cmd-init-012After successful write: add gitRoot to ProjectIndex.
BR-cmd-init-013Written ProjectManifest always includes $schema set to the canonical ProjectManifest JSON Schema URL.

User scenarios

From a repo root: npx @zortracks/skli init then prompts; or npx @zortracks/skli init -y --name my-app --tags ai,cursor. Then skli add can reference Packages.

Dependencies

Out of scope

  • GlobalManifest init.
  • Automatic migration of older manifests without metadata.
  • Advanced tag validation (beyond trim / non-empty).

Acceptance criteria

  • [x] skli init creates {gitRoot}/.skli/skli.json with metadata + empty maps.
  • [x] Walks up parent directories for git; error if none found.
  • [x] Confirmation if cwd ≠ git root; -y auto-accepts.
  • [x] Existing manifest → error unless --force.
  • [x] Flags and/or prompts for name, description, versioning, tags.
  • [x] -y applies defaults without prompt.
  • [x] ProjectIndex updated with the absolute project path.
  • [x] Visible in npx @zortracks/skli --help.
  • [x] Written ProjectManifest includes $schema (including --force).

Terminology

See domain-glossary — VersioningMode, ProjectManifest, ProjectIndex.

Implementation notes

src/commands/init.ts, src/lib/git.ts; prompts via @inquirer/prompts.

Released under the MIT License.