init
Use when .local/ is missing in this workspace, or to re-check your role, repositories 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 role, repositories 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. - List the roles with
ls .agents/roles. A role is a file name without.md, for examplebackend.mdis rolebackend. If.local/repos.jsonexists, rungrep '"role"' .local/repos.json. When it shows a role that is not empty and is in the list, use that role and tell the person "Using role <role> from .local/repos.json". Otherwise show the list, ask the person to choose one role, and wait for the answer. Never pick a role yourself. - Run
mkdir -p .local/drafts .local/handoffs. - If
.local/repos.jsondoes not exist, runcp .agents/templates/local/repos.json .local/repos.json. In every case, whether the file was just copied or already existed, open.local/repos.jsonand set theroleline to"role": "<role>",. Keepaddandskipas they are. - 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 5 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 5 just created
- Build the repository list. Open
repos.json. Take every entry ofrepositorieswhoseroleslist contains the role. Open.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 8, and keep it for the step 10 report. Remove every entry whosenameis inskip. When anameappears more than once, for example a name inaddthat the role already 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: role; each repository from step 8 with
cloned,present,plannedorfailedand its error, and eachaddname from step 7 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 6. - 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"}
]
}
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:
Role: backend
Repositories:
- payments: cloned
- ledger: present
- risks-front: planned
- 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.