init
Use when .local/ is missing in this workspace, or to re-check your repository selection and environment.
- License 许可
- MIT
- 最近更新
- 2026-10-30
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- init
- description
- Use when .local/ is missing in this workspace, or to re-check your repository selection and environment.
03 SKILL.md 正文
Init
Running init again is safe: it keeps existing values and only adds what is missing.
Steps
- Go to the workspace root: the nearest directory, walking up from where you are, where
test -f .agents/kit.jsonsucceeds. Run every later command in that directory. When you reach/and no directory on the way had.agents/kit.json, stop, tell the person "This is not a workspace: no .agents/kit.json found in this directory or above", and do nothing else. - Choose the repositories to clone.
- When
.local/repos.jsonexists, keep it as it is, tell the person "Using your saved selection from .local/repos.json", and go to step 3. - Otherwise open
repos.jsonand show the person every entry ofrepositories: itsnameandsummary, orplannedinstead of the summary when the entry'sstatusisplanned. - Ask the person which of them to clone. Any subset is valid,
allmeans every entry, and an empty answer means none. Never pick repositories yourself. - Check every name the person gives against the list. When a name is not in it, show the list again and ask again. Wait for a valid answer before you change anything.
- When
- Run
mkdir -p .local/drafts .local/handoffs. When step 2 chose the repositories, also runcp .agents/templates/local/repos.json .local/repos.jsonand put the chosen names, in the order the person gave them, into therepositorieslist of.local/repos.json. Leaveaddandskipempty. - Open
.agents/env.schema.json. Every entry ofvariableshasname,issued_byandhow_to_get.- Never open
.local/envwith a file editor, a read tool or a write tool. Reading it puts token values into your transcript, and a write tool can replace the whole file and lose values the person already filled in. Change.local/envonly with theprintfcommands below, and find names in it only with thegrep ... | cut -d= -f1command below, which prints names and never values. - Apostrophe rule: before you put
<issued_by>or<how_to_get>into aprintfcommand, replace every'inside them with'\''. For examplethe team's adminbecomesthe team'\''s admin. - To add the variable block for one variable, run
printf '%s\n' '# <name>: issued by <issued_by>; <how_to_get>' '<name>=' >> .local/env. Use>>, never>, so existing lines stay. - If
.local/envdoes not exist (test -f .local/envfails), runprintf '%s\n' '# Personal tokens for this workspace. Never commit, copy or print this file.' > .local/envto create it with the header line. Then add the variable block for every variable, in schema order. - If
.local/envexists, first runtest -z "$(tail -c1 .local/env)" || printf '\n' >> .local/env. It prints nothing and adds a final newline when the file lacks one, so an append does not glue a new line onto the last value. Then rungrep -E '^[A-Za-z_][A-Za-z0-9_]*=' .local/env | cut -d= -f1to list the names it already has. For every schema variable whosenameis not in that output, add its variable block. Do not change any other line.
- Never open
- Set the
.local/envpermissions:- If step 4 just created
.local/env, runchmod 600 .local/envand remember "created with 600". Skip the rest of this step. - Otherwise run
ls -l .local/envand look at the first 10 characters. If they are not-rw-------, runchmod 600 .local/envand remember "permissions fixed (were <first 10 characters>)". If they are-rw-------, remember "already 600".
- If step 4 just created
- Build the repository list. Open
.local/repos.jsonand take every name in itsrepositories. Openrepos.jsonand take the entry with thatnamefor each of them. Then, still in.local/repos.json, for every name inadd, take the entry ofrepos.jsonwith thatname; when there is none, mark the namefailedwith "not in repos.json", do not clone it in step 7, and keep it for the step 9 report. Remove every entry whosenameis inskip. When anameappears more than once, for example a name inaddthatrepositoriesalready includes, keep it once. Use each entry'sname,remoteandstatus. Mark every entry whosestatusisplannedasplanned: a planned repository does not exist yet and may have noremote, so it is never cloned. - For each repository in the list, one at a time:
- When it is marked
planned, run no command and go to the next repository. - Run
ls -d repos/<name>. When it exists, mark itpresentand go to the next repository. - Otherwise run
GIT_TERMINAL_PROMPT=0 git clone <remote> repos/<name>.GIT_TERMINAL_PROMPT=0makes a clone that needs a password fail instead of waiting for input. - When the command succeeds, mark it
cloned. When it fails, mark itfailedwith the first output line that starts withfatal:orerror:(theCloning intoline is not the error). When no line starts withfatal:orerror:, use the last non-empty output line instead. Then continue with the next repository.
- When it is marked
- Collect the environment, one command each:
git --version.command -v glab: output meansinstalled, no output meansmissing.command -v gh: output meansinstalled, no output meansmissing.command -v python3: output meansinstalled, no output meansmissing.grep -E '^[A-Za-z_][A-Za-z0-9_]*=$' .local/env | cut -d= -f1: the names of empty variables. This command prints only names. Never runcat .local/envand never print a value.
- Report to the person, in this order: each repository from step 7 with
cloned,present,plannedorfailedand its error, and eachaddname from step 6 that is not inrepos.jsonas<name>: failed: not in repos.json; git version; glab, gh and python3 asinstalledormissing; empty variables by name, ornone; the.local/envpermissions note from step 5. - Do not create a branch and do not commit.
initchanges only.local/andrepos/, which git ignores.
Example
Schema .agents/env.schema.json:
{
"variables": [
{"name": "TRACKER_TOKEN", "issued_by": "the tracker admin", "how_to_get": "request it in the access portal"}
]
}
The person chooses payments and ledger. New .local/repos.json:
{
"repositories": ["payments", "ledger"],
"add": [],
"skip": []
}
New .local/env:
# Personal tokens for this workspace. Never commit, copy or print this file.
# TRACKER_TOKEN: issued by the tracker admin; request it in the access portal
TRACKER_TOKEN=
Report:
Repositories:
- payments: cloned
- ledger: present
- billing-legacy: failed: fatal: could not read Username for 'https://git.example.com': terminal prompts disabled
git: git version 2.43.0
glab: installed
gh: missing
python3: installed
Empty variables: TRACKER_TOKEN
.local/env: created with 600
Without Python
This skill needs no Python: every step uses shell commands and git. When command -v python3 prints nothing, the report lists python3: missing.
04 同仓库更多 Skills
verify
Use when a change in __SERVICE__ must be checked before review
work-record
Use when you finished work on a tracker task and it must be recorded in the workspace through a merge request.
task-new
Use to create one story in a stream from the stream profile's story template, link it from its scope screens and open a merge request.
task-decompose
Use to split a stream at the decomposition stage into stories - list scope screens without a story, create the accepted stories and close the stage through a merge request.
task-context
Use to gather the context of a story key or a tracker id - its story, stream stage, scope screens, repositories, decisions, mockups and work records.
repos-sync
Use to update clones of your repositories under repos/ and see their branch, lag and uncommitted changes.