name: kg-init description: "This skill should be used when the user asks to initialize, bootstrap, reset, or prepare a kg-skill wiki, says 'kg-skill 처음 설정', 'wiki 초기화', '스키마 pin 만들기', or invokes /kg-init. Creates wiki/, copies schema, seeds index/log/hot, validates setup. Idempotent — never overwrites existing wiki content." trigger: /kg-init
/kg-init — Bootstrap a Wiki for the Evolving Mini-Ontology
This is the single source of "wiki is ready to use v1". Every other kg skill that writes to the wiki assumes this has run.
Activate When
- User invokes
/kg-init(with or without project path) - User asks "kg-skill 처음 설정", "wiki 초기화", "스키마 pin 만들기"
- A new project needs the kg wiki layer
- Pin file is missing or schema upgrade requested
Do Not Activate When
- Wiki already exists and contains content → use
/kg-orientfor status,/kg-schema pull-globalfor schema upgrade - User wants to ingest content →
/kg-ingest - User wants to query →
/kg-query
Preconditions
- Global schema exists at
~/.claude/skills/kg/schema/ - Templates exist at
~/.claude/skills/kg/templates/ - A project directory where the wiki should live
Flow
Resolve project root
- If path argument given, use it. Otherwise cwd.
- Wiki root :=
<project>/wiki/(create if missing)
Create folder structure (idempotent —
mkdir -psemantics)<project>/wiki/ ├── .schema/ │ └── migrations/ ├── .schema-proposals/ ├── entities/ ├── concepts/ ├── procedures/ ├── experiences/ ├── heuristics/ ├── decisions/ ├── sources/ └── queries/Copy global schema to per-wiki pin (only if pin doesn't already exist)
cp ~/.claude/skills/kg/schema/core.yaml wiki/.schema/ cp ~/.claude/skills/kg/schema/relations.yaml wiki/.schema/ cp ~/.claude/skills/kg/schema/frontmatter.yaml wiki/.schema/ cp ~/.claude/skills/kg/schema/migrations/*.yaml wiki/.schema/migrations/
3b. Copy research policy (only if absent):
cp ~/.claude/skills/kg/schema/research-policy.yaml wiki/.schema/research-policy.yaml
Create the research queue staging folder:
mkdir -p wiki/.research-queue/{approved,rejected}
Write
wiki/.schema/pin.yaml(only if absent)pinned_version: 1 pinned_at: YYYY-MM-DD source: global source_version: 1 notes: Initial bootstrap. Run /kg-schema pull-global to upgrade.Seed
wiki/index.md,wiki/log.md, andwiki/hot.md(only if absent)index.md: empty category stubs for all 10 folderslog.md: first entry[YYYY-MM-DD] init | bootstrapped to v1hot.md:--- title: Hot Cache type: meta date_modified: YYYY-MM-DD --- # Hot Cache ## Current Focus (initialized — no operations yet) ## Recent Activity - [YYYY-MM-DD] wiki bootstrapped to schema v1 ## Key Tensions / Open Questions (none yet)
5b. Seed folder-level _index.md stubs for each content folder
Each folder gets a lightweight _index.md:
---
title: <Folder> Index
type: folder-index
date_modified: YYYY-MM-DD
---
# <Folder>
(empty — pages will be listed here as they are created)
Main index.md links to these: - [[<folder>/_index|<Folder>]] — N pages.
Run validator against the per-wiki pin
python3 ~/.claude/skills/kg/schema/tools/validate.py --schema-dir wiki/.schemaExpected: exit 0 (contract check runs against templates, no page errors).
Optional: install
/graphifycompanion skill (only on first-time setup, ask before running)graphify install --platform claudeThis adds
~/.claude/skills/graphify/SKILL.mdso/kg-updateand other skills can soft-depend on graphify v0.8.x tools. Preferuv tool install graphifyyto putgraphifyon PATH first.Note: graphify's own
/graphify <path> --wikiproduces an agent-crawlable markdown wiki straight from the graph — useful as raw scaffolding/stubs, but it is not kg's ontology-structured wiki (no 7-class frontmatter, no schema pin). kg-init owns the ontology wiki; treat a--wikiexport as another source to/kg-ingest, not a substitute for this bootstrap.
Idempotency contract
- Running
/kg-inittwice MUST NOT:- Overwrite an existing
pin.yaml - Clobber
index.md,log.md,hot.md, or any content page - Change migration files
- Overwrite an existing
- Running on a wiki whose pin is older than global prints a notice suggesting
/kg-schema pull-globalbut does NOT pull automatically.
Output Contract
Init result: PASS | PARTIAL | FAIL
Wiki root: <path>
Pin: v<N> (created | existing | missing-global)
Folders created: <N>
Folders verified existing: <N>
Schema files copied: <list | skipped (existing)>
Research policy: copied | skipped | missing-global
Seed files: index.md=<created|kept>, log.md=<created|kept>, hot.md=<created|kept>
Folder _index.md stubs: <N created, M kept>
Validator: PASS | FAIL (<details if fail>)
graphify companion: installed | skipped | not-asked
Caveats:
- <existing wiki preserved | global schema missing | none>
Next command:
- /kg-orient | /kg-ingest <file> | /kg-schema list
Exceptions and Escalation
- Global schema directory missing (
~/.claude/skills/kg/schema/absent) → stop and report exact missing path. Do not proceed. wiki/.schema/pin.yamlalready exists → skip write (do not overwrite). Note in output as "Pin: existing".wiki/index.md,wiki/log.md, orwiki/hot.mdexists → preserve. Note in output as "kept".- Validator fails → report exact failing file path. Do not suggest
/kg-ingestuntil fixed. - Migration files exist → never modify. They are append-only history.
Quality Gates
Before final answer:
- No existing wiki content was overwritten (idempotency)
- Pin records source version
- All 10 folders exist (create or verify)
- Validator passed against per-wiki pin
- log.md contains init entry with date