with one click
codeguide-setup
// Set up, refresh, or activate codeguide (inline or sibling). Detects context automatically: first-time root, refresh, or subfolder.
// Set up, refresh, or activate codeguide (inline or sibling). Detects context automatically: first-time root, refresh, or subfolder.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | codeguide-setup |
| description | Set up, refresh, or activate codeguide (inline or sibling). Detects context automatically: first-time root, refresh, or subfolder. |
| argument-hint | [--sibling [<url>]] [--branch <name>] [.cs .py .ts] |
Set up or refresh codeguide for the current git repo. Two placement modes:
<repo>/_codeguide/. @git-commit stages them alongside source changes.--sibling): files live in a separate git repo next to the target repo ā <container>/<repo>.codeguide/ by default, or <container>/codeguide/ when the target is hub-form (directory named exactly hub). The sibling repo has its own history. The target repo is never modified.In both modes, any source-folder subtree can also carry its own _codeguide/ (subfolder workspace) that points back to the root via root.txt. In sibling mode the subfolder's _codeguide/ lives under the same relative path inside the sibling repo, not in the target repo.
Does not commit in inline mode. Commits in the sibling repo when in sibling mode (the sibling's history is independent).
After parsing flags (Step 1) and detecting the git toplevel (Step 2), run python ${CLAUDE_PLUGIN_ROOT}/scripts/resolve.py --json to discover existing codeguide state. The script prints {mode, cg_root, sibling_anchor, found}. The found flag ā together with mode, cg_root, and sibling_anchor ā drives the first-time / refresh / subfolder dispatch in Step 5. Do NOT halt on found == false; that is the expected result for first-time setup.
<root>/_codeguide/
āāā config.yaml ā source file extensions (you own this)
āāā local-rules.md ā repo-specific doc rules (you own this)
āāā Overview.md ā repo routing table (you own this)
āāā cgignore.md ā system-level ignores (plugin-owned)
āāā cgexclude.md ā module exclusions (you own this)
āāā modules/
āāā DocumentationGuide.md ā how to write docs (plugin-owned)
Where <root> is either the target repo (inline) or <sibling-anchor>/<rel-path>/ (sibling).
Parse flags from $ARGUMENTS:
--sibling or --sibling <url> ā sibling mode; an optional URL argument (the next non-flag token following --sibling) clones from that URL instead of git init.--branch <name> ā branch to use when cloning or initializing the sibling anchor; requires --sibling <url> (a URL must be present). If --branch is given without a URL in --sibling, stop with the error: "--branch requires a URL ā use --sibling <url> --branch <name>".. (e.g. .cs .py) ā source extensions for config.yaml.Detect git toplevel: Run git rev-parse --show-toplevel. If not in a git repo, stop with an error.
Resolve existing codeguide state. See ## Resolution above. Parse the JSON for {mode, cg_root, sibling_anchor, found} to drive the first-time/refresh/subfolder dispatch in Step 5.
Compute target root <root>:
<root> = cwd (first-time root) or whichever folder the resolve result points at.<sibling-anchor> by invoking python ${CLAUDE_PLUGIN_ROOT}/scripts/_sibling.py codeguide <git-toplevel> via subprocess. Parse the printed path..codeguide-root exists at the git-toplevel, use its contents instead (single absolute or relative-to-toplevel path). Do NOT auto-create this file; users who want a non-default anchor write it themselves.<sibling-anchor> does not exist yet, create it according to which flags were given:
--sibling only): git init <sibling-anchor>--branch: git clone <url> <sibling-anchor>--branch <name>: first run git ls-remote --heads <url> <branch>, then:
git clone -b <branch> --single-branch <url> <sibling-anchor>git init <sibling-anchor>, then git -C <sibling-anchor> remote add origin <url>, then git -C <sibling-anchor> checkout -b <branch> (orphan branch; do NOT push at setup time ā first commit pushes)<root> = <sibling-anchor> / <rel-path> where <rel-path> = cwd.relative_to(git-toplevel).<sibling-anchor> already exists and is a git repo: <root> = <sibling-anchor> / <rel-path>. --branch is ignored ā the anchor has its own branch history.Determine mode (first-time / refresh / subfolder):
found == false AND <root> has no _codeguide/ ā first-time root setup<root> has _codeguide/config.yaml ā root refreshfound == true and <root>/_codeguide/root.txt exists ā subfolder refreshfound == true and <root> is under an ancestor's _codeguide/ reach, but <root> has no _codeguide/ OR has one without root.txt ā new subfolder (ask user to confirm before proceeding)Check prerequisites: Inline ā verify cwd's git repo exists. Sibling ā verify <sibling-anchor> is a git repo (created above if needed).
Read plugin files from ${CLAUDE_PLUGIN_ROOT}:
templates/DocumentationGuide.mdtemplates/config.yamltemplates/local-rules.mdtemplates/cgignore.mdtemplates/cgexclude.mdtemplates/codeguide-overview-starter.mdCreate directories: <root>/_codeguide/modules/.
Copy plugin-owned files:
templates/DocumentationGuide.md ā <root>/_codeguide/modules/DocumentationGuide.mdCreate user-owned files (only if they don't exist):
<root>/_codeguide/cgignore.md ā copy from template (user adds repo-specific entries).<root>/_codeguide/config.yaml ā if $ARGUMENTS contained extensions, write a config with those extensions. Otherwise copy the template.<root>/_codeguide/local-rules.md ā copy from template.<root>/_codeguide/cgexclude.md ā copy from template.<root>/_codeguide/Overview.md ā read templates/codeguide-overview-starter.md, strip the leading HTML comment, and write the body.Commit (sibling mode only): In the sibling repo, git -C <sibling-anchor> add -A && git -C <sibling-anchor> commit -m "codeguide-setup: init <rel-path>" (use init root when <rel-path> is empty).
Report what was created and where (inline vs sibling; print <root>).
Read plugin source files from ${CLAUDE_PLUGIN_ROOT}:
templates/DocumentationGuide.mdtemplates/config.yamlOverwrite plugin-owned files:
<root>/_codeguide/modules/DocumentationGuide.mdMerge config schema: For each key in the template that is missing from <root>/_codeguide/config.yaml, add it with its default value and comment. Do not change existing values.
Create <root>/_codeguide/cgexclude.md if it doesn't exist.
Commit (sibling mode only): codeguide-setup: refresh <rel-path>.
Report what was updated.
Update <root>/_codeguide/root.txt with the current resolved path to the root _codeguide/.
Create <root>/_codeguide/cgexclude.md if it doesn't exist.
Commit (sibling mode only): codeguide-setup: subfolder refresh <rel-path>.
Report what was updated.
Report findings: "Found root _codeguide/ at <path> (mode: inline|sibling)." If <root> already has a _codeguide/ directory without root.txt, add: "<root> already has _codeguide/ with files: <list>. Promote this folder to a subfolder workspace without touching existing files?" Otherwise: "Set up this folder as a subfolder workspace?"
Wait for user confirmation. If denied, stop.
Create <root>/_codeguide/ directory if it does not exist. If it already exists, leave existing files untouched ā this step is the promote case.
Create <root>/_codeguide/root.txt with the resolved path to the ancestor _codeguide/.
Create <root>/_codeguide/cgexclude.md from template ā only if it does not already exist.
Commit (sibling mode only): codeguide-setup: activate subfolder <rel-path>.
Report what was created (distinguish "created new subfolder workspace" vs "promoted existing _codeguide/ to subfolder workspace").
@git-commit stages and commits..gitignore, don't drop marker files, don't auto-create .codeguide-root ā users who want that override file create it themselves.