--- name: ckb-create description: Create a brand-new shared Cascade Knowledge Base in a folder and publish it to an empty git remote, so colleagues can join it straight away — fetches the current template, scaffolds the KB with that template's own ckb-init, commits on `main`, adds the given URL as `origin` and pushes. Installed in a user's profile, so it works from any folder. Use for "create a new wiki in this folder with this origin", "start a shared knowledge base", "new KB for the team", "set up a wiki and push it to our git server". Not for a local-only scaffold with no remote (that is ckb-init inside a KB) or for joining a KB that already exists on the remote (that is ckb-join). --- # Create a shared Cascade KB ## Purpose One action from "I have an empty remote repo" to "the team can clone a working KB". This skill lives in a person's profile (`~/.claude/skills/`), not in any KB, so it never gets upgraded with the template. It therefore holds **no scaffold knowledge of its own**: it fetches the template and follows the `ckb-init` that ships with it, then does the publishing that `ckb-init` deliberately leaves out. Never pushes to a remote that already has commits, never force-pushes, never creates the remote repository itself (that is the git host's job and the user's permissions). ## How to run this skill ### Step 1 — Collect the three inputs - **Target folder** — where the new KB lives on this machine. Resolve to an absolute path and say it back before writing anything. A relative path is relative to the current working directory, not to any KB. - **Origin URL** — the remote repository, already created on the host (GitHub, GitLab, Gitea, Azure DevOps…) and **empty**: no README, no licence, no `.gitignore`. If the user has not created it yet, tell them to, and to leave "initialise with README" unticked. - **Template channel** (optional) — `main` unless the user names `test`, `experimental`, or a fork/mirror URL. Same rules as `ckb-init`'s "Which branch" table. Ask only for what is missing, in one message. ### Step 2 — Pre-flight Run these and stop on the first failure, reporting git's own error: ```bash git --version git config user.name; git config user.email git ls-remote ``` - **No git identity** — every log entry and commit in a Cascade KB carries the author, so a team KB needs one. Ask for name and email and set them with `git config --global` only on a yes; otherwise stop. - **`ls-remote` fails** — authentication or a wrong URL. Report the raw error, suggest checking the URL and that the user can push to it (SSH key, credential helper, personal access token). Don't guess a corrected URL. - **`ls-remote` prints any refs** — the remote is not empty. Stop: "That remote already has history. If it is an existing KB, say *join the knowledge base at ``* instead; if it only has an auto-generated README, delete the repo and recreate it empty, or tell me to proceed and I'll stop before pushing." Never merge an unrelated history here. - **Target folder** — apply `ckb-init`'s Step 2 rules (an existing `wiki/` or `AGENTS.md` means stop and ask). Additionally, if the target is already inside a git work tree (`git -C rev-parse --is-inside-work-tree`), stop: a shared KB needs its own repository, not a subfolder of another. ### Step 3 — Fetch the template ```bash rm -rf git clone --depth 1 --branch git -C rev-parse --short HEAD cat /VERSION ``` `` defaults to `https://git.wierzbowa.cloud/michal/ckb.git`. `` is a fresh temp directory outside the target (`mktemp -d`, or the session scratchpad). Note the URL, branch, short hash and `VERSION` for the report. ### Step 4 — Scaffold with the template's own `ckb-init` Read `/.agents/skills/ckb-init/SKILL.md` (and its `references/edge-cases.md` if a case comes up) and follow it with: - **template source** = the scratch clone (its Step 3a, already done — do not clone again); - **target** = the folder from Step 1 (its Steps 1–2 are already done); - `ckb.yaml`'s `template:` block = the template URL and branch from Step 3. Ask the questions `ckb-init` asks (the `ABOUT.md` purpose sentence, the `LICENSE` copyright line). Those answers matter more for a shared KB, since everyone will see them. **Two overrides to `ckb-init`, because this KB is shared:** - Its Step 11 is **not optional** and not "ask first": initialise the repository on `main` — the branch `ckb-sync-changes` assumes: ```bash git -C init -b main ``` (On git older than 2.28: `git init` then `git symbolic-ref HEAD refs/heads/main`.) - Its "don't add a remote and don't push" is replaced by Step 6 below. If `ckb-init` in the fetched template differs from what this skill expects (renamed steps, a new step), the fetched `ckb-init` wins: it is the current contract, this skill is only the wrapper. ### Step 5 — First commit ```bash cd test -L CLAUDE.md && test -L .claude/skills # both must be symlinks git add . git status --short | head -50 # show what goes in git commit -m "Initialize Cascade Knowledge Base from ckb template v" ``` `git add .` is safe here and only here: the folder holds nothing but the fresh scaffold, and its `.gitignore` is already in place. If `git status` shows anything that is not scaffold (a stray `.env`, files that were in the folder before), stop and ask before committing it. If either symlink check fails, fix it before committing (`ln -s AGENTS.md CLAUDE.md`, `ln -s ../.agents/skills .claude/skills`) — a team member who clones a KB whose `CLAUDE.md` is a plain copy gets a stale system prompt. ### Step 6 — Publish ```bash git remote add origin git push -u origin main git ls-remote origin refs/heads/main # must equal: git rev-parse HEAD ``` If the push is rejected, report the raw error and stop — the remote gained history after Step 2, or the user lacks push rights. Never `--force`. ### Step 7 — Clean up and report ```bash rm -rf ``` Tell the user, briefly: - the folder, the origin URL, and that `main` is pushed and tracking `origin/main`; - the template source (URL, branch, short hash, `VERSION`); name the channel in words if it is not `main`; - what they answered for `ABOUT.md` and `LICENSE`; - **how colleagues join**, as a line they can forward: > Install the `ckb-join` skill, then say: *join the knowledge base at > ``*. Or by hand: `git clone ` and open the > folder in your agent. - that they must grant those colleagues access on the git host — this skill cannot; - next step: open the folder in the agent (`cd && claude`) so the KB's own skills load, drop material into `raw/inbox/` and say *Ingest*; "sync changes" shares the result. ## Edge cases - **Remote has only a host-generated README/licence** — still "not empty". Recreating the repo empty is cleaner than merging; offer that first. If the user insists on keeping it, finish Steps 3–5, then hand over to the new KB's own `ckb-sync-changes`, whose unrelated-histories path asks how to merge. - **Template clone fails** — report the raw error and stop. Don't fall back to a stale `ckb-init` in the user's profile or to a scaffold from memory. - **The user runs this from inside another KB** — fine; the target must still be a separate folder outside it (`ckb-init`'s edge case on nesting applies). The current KB's own rules (log, workload note) apply to the current session as usual; nothing is written into the current KB. - **Windows** — `ckb-init`'s symlinks need Developer Mode or an elevated shell, and `git config core.symlinks true`. If symlinks can't be created, stop before Step 5 and say so; don't commit copies. - **SSH vs HTTPS** — use the URL exactly as given; the joiner can use either form of the same repository. --- *Licensed under the Apache License, Version 2.0 — .*