corp-new · diff
git:20260601.33c4779 to git:20260929.b858fd2
81 added, 106 removed. Audit A to A.
---
name: corp-new
- description: Use when creating, verifying, or registering a private corp-* department repository for a founder or company operating system, including local repo setup, GitHub repository creation or cloning, safe synchronization, and registration in an HQ Markdown file.
+ description: Создаёт новый отдел штаба — папку с файлом правил и папкой скиллов, приватный репозиторий на GitHub и связь со штабом в правилах в обе стороны. Если штаба ещё нет, сначала ставит его из agent-starter. Применять по /corp-new, «создай отдел», «новый отдел», «заведи отдел <домен>».
---
- # Corp New
-
- Create or verify a private `corp-*` department repository and register it in a local HQ Markdown file.
-
- ## What The Skill May Change
-
- After approval, this skill may create a local folder, initialize git, create a private GitHub repository, clone an existing repository, commit a minimal README, push committed work, fetch from origin, and edit one HQ table row.
-
- Stop and ask for explicit approval after the dry-run summary before any create, clone, commit, push, or HQ edit.
+ # corp-new: новый отдел штаба
- ## Configuration
+ Штаб это главная папка работы с агентом: файл правил, `me.md`, карта отделов. Отдел это соседняя папка штаба со своим файлом правил и скиллами, например `corp-sales` или `corp-content`. Отдел знает свой штаб, штаб знает свои отделы: связь записана в правилах с обеих сторон.
- Resolve configuration in this order: explicit user request, environment variables, project instructions, then documented defaults.
+ Скилл идёт по шагам и отвечает таблицей ✓/✗. Правила отдела за человека он не пишет: ставит каркас с пустыми местами, их человек заполняет сам или в интервью (`interview-me`). Чужие файлы не трогает, незакоммиченную работу не выбрасывает.
- Required values from the user or project config:
+ Команды даны для macOS и Linux (zsh, bash). На Windows агент делает то же средствами PowerShell.
- | Value | Env var | Default |
- |---|---|---|
- | Department label | `DEPARTMENT_LABEL` | ask the user |
- | Department domain | `DEPARTMENT_DOMAIN` | ask the user |
- | GitHub owner or org | `GITHUB_OWNER` | ask the user |
- | Local repositories root | `CORP_REPOS_ROOT` | `~/Documents/GitHub` |
- | HQ Markdown file | `HQ_FILE` | ask the user |
- | Repository prefix | `REPO_PREFIX` | `corp-` |
+ ## 1. Найти штаб
- Optional values:
+ Штаб узнаётся так же, как в скилле `hq` (шаг 1): папка с `me.md` или `stack/harness.md`. Где искать, по порядку:
- - `DEPARTMENT_TABLE_HEADING`: heading or marker near the department table.
- - `DEPARTMENT_SLUG`: explicit slug override.
+ ```sh
+ for d in . .. ../hq ~/Documents/GitHub/hq ~/hq; do
+ { [ -e "$d/me.md" ] || [ -e "$d/stack/harness.md" ]; } && (cd "$d" && pwd -P)
+ done | sort -u
+ ```
- Ask before making changes if the department label, department domain, `GITHUB_OWNER`, or `HQ_FILE` cannot be resolved. Repositories are private by design; do not offer public visibility unless the user explicitly overrides the skill's safety model.
+ - Нашёлся один — это штаб; дальше его путь `HQ`, папка репозиториев `ROOT` — его родитель.
+ - Нашлось несколько — спросить одной строкой, какой.
+ - Открыт отдел, и в его файле правил есть ссылка на штаб (`../<папка>`) — штаб берётся по ней.
+ - Не нашлось — шаг 2.
- ## Preflight
+ ## 2. Штаба нет: поставить из agent-starter
- Before creating or editing anything:
+ Папка штаба по умолчанию — `~/Documents/GitHub/hq`, если есть `~/Documents/GitHub`; иначе спросить одной строкой, где держать репозитории. Путь только латиницей.
- ```bash
- git --version
- gh auth status
- gh api user --jq '.login'
- test -d "$CORP_REPOS_ROOT"
- test -f "$HQ_FILE"
+ ```sh
+ ROOT=~/Documents/GitHub; HQ="$ROOT/hq"
+ git clone https://github.com/serejaris/agent-starter.git "$HQ"
+ git -C "$HQ" remote rename origin upstream # обновления стартера — git pull upstream main
+ mkdir -p "$HQ/stack"
```
- Reject unsafe targets:
+ Дальше в папке штаба пройти скилл `hq` этого штаба (`$HQ/.agents/skills/hq`): он определит харнес, поставит главный файл правил и `me.md`. Пустые правила штаба заполняются по образцу из шага 5 скилла `hq`, словами человека. Штаб на GitHub — только если человек попросил: приватным репозиторием, как отдел в шаге 5.
- - archive/history folders for `HQ_FILE`;
- - slug that does not match `^corp-[a-z0-9][a-z0-9-]*$` unless the user explicitly overrides;
- - ambiguous ownership when an existing department could already own the domain.
+ Проверка: в `$HQ` есть `AGENTS.md` и `CLAUDE.md` (один из них симлинк на другой), `.agents/skills/hq`, `stack/harness.md`.
- ## Read-Only Preflight Result
+ ## 3. Имя отдела
- Report this before the dry run:
+ Имя папки — `corp-<домен>` латиницей в нижнем регистре: `corp-sales`, `corp-legal`. Человек назвал отдел по-русски — предложить имя одной строкой и взять его ответ. Если домен уже есть у другого отдела штаба (карта отделов в правилах штаба) — спросить, новый ли это отдел, до любых правок.
- ```text
- Local folder: exists | missing | conflict
- GitHub repo: exists | missing | inaccessible
- HQ row: exists | missing | ambiguous
- Proposed action: create | clone | register | update existing row | verify only
+ ```sh
+ SLUG=corp-<домен>; D="$ROOT/$SLUG"
+ test -d "$D" && echo "папка есть"
+ command -v gh >/dev/null && gh repo view "$(gh api user -q .login)/$SLUG" --json visibility,url 2>/dev/null
+ grep -n "$SLUG" "$HQ/AGENTS.md" "$HQ/CLAUDE.md" 2>/dev/null
```
- ## Dry Run Summary
+ - Папка есть — каркас не ставить: только связь (шаг 6) и проверка (шаг 7).
+ - Папки нет, а репозиторий на GitHub есть — `gh repo clone <владелец>/$SLUG "$D"`, дальше шаг 6.
- Before making changes, show a short summary:
+ ## 4. Каркас отдела
- ```text
- Department: <Human label>
- Slug: <corp-slug>
- Local path: <CORP_REPOS_ROOT>/<corp-slug>
- GitHub repo: <GITHUB_OWNER>/<corp-slug>
- HQ file: <HQ_FILE>
- HQ row: | <Human label> | `<local path>`; [GitHub](https://github.com/<GITHUB_OWNER>/<corp-slug>) | <domain> |
+ ```sh
+ mkdir -p "$D/.agents/skills" "$D/.claude"
+ ln -s AGENTS.md "$D/CLAUDE.md"
+ ln -s ../.agents/skills "$D/.claude/skills"
+ git -C "$D" init -b main
```
- Stop here and ask for explicit approval. Continue only after the user approves the proposed mutations.
+ `$D/AGENTS.md` — ровно этот каркас, `<HQ>` — имя папки штаба:
- ## Workflow
+ ~~~markdown
+ # <slug>
- 1. Normalize the department.
- - Prefer `<REPO_PREFIX><domain>` as the slug.
- - Keep the human label short, for example `Media`, `Legal`, `Analytics`.
- - Keep the domain description operational, for example `media assets and publishing workflows`.
+ Это отдел штаба `../<HQ>`: там общие правила, карта отделов и `me.md`.
- 2. Inspect existing state.
- - Local: `test -d "$CORP_REPOS_ROOT/$SLUG"`.
- - GitHub: `gh repo view "$GITHUB_OWNER/$SLUG" --json name,visibility,url,sshUrl,defaultBranchRef`.
- - HQ: `rg -n "$SLUG|$DEPARTMENT_LABEL" "$HQ_FILE"`.
+ ## Назначение
- 3. Create missing resources.
- - If local folder is missing and GitHub exists, clone it into `$CORP_REPOS_ROOT/$SLUG`.
- - If GitHub is missing and local folder is a git repo, create a private remote and push committed work:
- `gh repo create "$GITHUB_OWNER/$SLUG" --private --source "$CORP_REPOS_ROOT/$SLUG" --remote origin --push`.
- - If both are missing, create the local folder, initialize git, add a minimal `README.md`, commit, create the private GitHub repo, and push.
- - If local exists with unrelated uncommitted work, preserve it. Push only committed changes unless the user explicitly asks to commit current work.
+ <одна-две строки: что хранит и делает этот отдел>
- 4. Sync safely.
- - Run `git -C "$CORP_REPOS_ROOT/$SLUG" fetch origin`.
- - Check `git -C "$CORP_REPOS_ROOT/$SLUG" status --short --branch`.
- - Push only when the current branch is ahead and no pull/rebase decision is needed.
- - Never force-push, reset, delete, or discard user work.
+ ## Канон
- 5. Register in HQ.
- - Add or update exactly one row in the department table:
- `| <Human label> | \`<local path>\`; [GitHub](https://github.com/<GITHUB_OWNER>/<SLUG>) | <domain> |`
- - Keep the HQ edit minimal.
- - Do not copy department content into HQ; link to the owner repo.
+ - <путь/файл> — <что здесь живёт>.
- 6. Verify.
- - Confirm GitHub visibility is `PRIVATE`.
- - Confirm default branch and URL from `gh repo view`.
- - Confirm local remote points to the configured GitHub repo.
- - Show the exact HQ row changed.
+ ## Границы
- ## Minimal README
+ - Секреты, токены, пароли и платёжные данные не хранить.
+ - Не копировать содержимое отдела в другие папки; ставить ссылку на файл-владелец.
+ - Карту отделов не дублировать: она живёт в штабе.
- When bootstrapping an empty department repo, use a small neutral README:
+ ## Проверка
- ```markdown
- # <Department Name>
+ ```bash
+ git diff --check
+ ```
+ ~~~
- Owner repository for <department domain>.
+ `$D/README.md` — одна строка: `<slug> — <домен одной строкой>. Правила для агентов — в AGENTS.md.`
- ## Scope
+ `.agents/skills/` остаётся пустой, пока у отдела не появятся свои скиллы.
- - <primary responsibility>
- - <secondary responsibility>
+ ## 5. Приватный репозиторий
- ## Source of truth
+ Нужен `gh` с входом в аккаунт (`gh auth status`). Нет — пропустить шаг и сказать об этом в отчёте.
- This repository owns department-specific workflows and artifacts. Cross-department routing lives in the HQ file.
+ ```sh
+ git -C "$D" add -A && git -C "$D" commit -m "chore: init $SLUG"
+ gh repo create "$SLUG" --private --source "$D" --remote origin --push
```
- ## Final Response
+ Репозиторий только приватный: в отделах рабочие данные человека.
- Report only verified facts:
+ ## 6. Связь со штабом в правилах
- ```text
- Created or verified: <GITHUB_OWNER>/<SLUG>
- Visibility: PRIVATE
- Local path: <path>
- GitHub: <url>
- Default branch: <branch>
- HQ row: <exact row>
- Skipped: <anything intentionally left untouched>
+ - **Штаб → отдел.** В карту отделов файла правил штаба (или в `projects.md`, если карта вынесена туда) дописать отдел в том формате, который там уже есть: таблица — строкой таблицы, список — пунктом. Путь всегда `../<slug>`, домен — коротко: `- <название>: \`../<slug>\` — <домен>`. Если правила штаба сами говорят, какие отделы вписывать в карту, — следовать им.
+ - **Отдел → штаб.** Первая строка после заголовка `AGENTS.md` отдела: «Это отдел штаба `../<HQ>` …» (каркас из шага 4). У существующего отдела без неё — дописать её.
+
+ Коммит в штабе — только этой правки; push — если так велят правила человека.
+
+ ## 7. Проверка и отчёт
+
+ ```sh
+ [ "$(readlink "$D/CLAUDE.md")" = AGENTS.md ] && echo "✓ CLAUDE.md -> AGENTS.md"
+ [ "$(readlink "$D/.claude/skills")" = ../.agents/skills ] && echo "✓ .claude/skills -> ../.agents/skills"
+ grep -q "\.\./$(basename "$HQ")" "$D/AGENTS.md" && echo "✓ отдел ссылается на штаб"
+ grep -q "\.\./$SLUG\|\`$SLUG\`" "$HQ/AGENTS.md" "$HQ/CLAUDE.md" "$HQ/projects.md" 2>/dev/null && echo "✓ штаб ссылается на отдел"
+ gh repo view "$(gh api user -q .login)/$SLUG" --json visibility -q .visibility 2>/dev/null # PRIVATE
```
- ## Boundaries
+ Связь в обе стороны проверяет и скилл `hq` (шаг 5): после создания отдела «проверь штаб» даёт по нему ✓.
- This skill manages department repository registration. Product claims, pricing, secrets, billing evidence, customer data, and operational runbooks belong in the appropriate owner repository and must not be copied into the HQ index.
+ Отчёт человеку — таблица ✓/✗ по шагам, строка, добавленная в карту отделов штаба, и что заполнить дальше: назначение и канон отдела.