---
name: ultra-skill-author-local
description: Skill-factory Fase 1 — generate one cc-architect-catalog draft from a local source with IP-hygiene
argument-hint: "<source-file> [--fg | --quick]"
model: opus
allowed-tools: Agent, Read, Glob, Grep, Bash
---

# Ultra Skill Author Local v1.0

Manuell, én-skill-om-gangen-generator for `cc-architect-catalog`.
Konsumerer EN lokal kildefil (`.md` eller `.txt`), trekker ut konsept,
drafter SKILL.md-innhold med 9-felts frontmatter, og kjører IP-hygiene
mot kilden. Resultatet legges i `skills/cc-architect-catalog/.drafts/`
for manuell review og promotion (`mv` til katalog-rot).

Dette er Channel 2 av skill-factory-strategien:
manuell, ikke automatisk; én skill om gangen, ikke batch; lokal
kildefil, ikke URL eller remote.

```
Manual flow:
  Pick a local source → /ultra-skill-author-local <source> → review .drafts/<slug>.md
  → if happy: mv .drafts/<slug>.md to catalog root
  → if rejected: pipeline deletes draft; pick another source or rewrite by hand
```

**Designprinsipp — én ansvarlig kjede.** Pipelinen er sekvensiell
(ikke parallell). Hvert steg konsumerer forrige stegs output.
`concept-extractor` bestemmer feature/layer; `skill-drafter` skriver
draft; `ip-hygiene-checker` skårer mot kilden og enten stempler scoren
i frontmatter eller sletter draftet.

## Phase 1 — Parse arguments

Parse `$ARGUMENTS`:

1. **Positional argument** (PÅKREVD) — sti til kildefil. Relativ sti
   tolkes mot CWD.
2. **`--fg`** — foreground execution. Currently the only supported mode
   in fase-1; flag accepted for consistency med pipeline-konvensjonen
   (`--fg` finnes i alle `/ultra*-local`-kommandoer). Background-modus
   er out-of-scope for fase-1 MVP.
3. **`--quick`** — hopp over Phase 4 (IP-hygiene) i orchestratoren.
   Emit BIG WARNING: draftet får ikke ngram_overlap_score, og det er
   IKKE klart for review. Brukes kun til å teste drafting-pipelinen i
   isolasjon.

Hvis positional argument mangler, vis usage og stopp:

```
Usage: /ultra-skill-author-local <source-file> [--fg] [--quick]

A source file is required. The source must be a local .md or .txt file
on a Claude Code feature topic (hooks, subagents, skills, output-styles,
mcp, plan-mode, worktrees, background-agents).

Modes:
  default   Run the pipeline foreground (concept → draft → IP-hygiene)
  --fg      Same as default; flag accepted for consistency
  --quick   Skip IP-hygiene scoring (for testing the drafting pipeline)

Examples:
  /ultra-skill-author-local ./docs/hooks-recipes.md
  /ultra-skill-author-local ./docs/mcp-pattern-notes.md --fg
  /ultra-skill-author-local ./docs/draft-source.md --quick

Pipeline position (skill-factory Channel 2):
  curated local source → /ultra-skill-author-local
  → skills/cc-architect-catalog/.drafts/<slug>.md
  → manual review → mv to catalog root
```

Ikke fortsett forbi dette steget hvis kildefil mangler.

## Phase 2 — Validate source

Bash:

```bash
test -f "<source>" && echo "OK"
```

Hvis filen ikke finnes: stopp med tydelig feilmelding.

Sjekk extension:

```bash
case "<source>" in
  *.md|*.txt) ;;
  *) echo "Error: source must be .md or .txt"; exit 1 ;;
esac
```

Sjekk størrelse:

```bash
size=$(wc -c < "<source>")
if [ "$size" -gt 204800 ]; then
  echo "Error: source > 200 KB (got $size bytes) — too large for fase-1 MVP"
  exit 1
fi
```

200 KB-grensen kommer fra brief §Non-Goals (ingen multi-fil eller
mega-source-håndtering i fase 1).

Hvis quick-modus: emit BIG WARNING:

```
WARNING: --quick mode active.
The draft will NOT be scored against the source.
ngram_overlap_score will remain null.
DO NOT promote this draft to the catalog root without re-running
without --quick or scoring it manually.
```

## Phase 3 — Launch the orchestrator

Launch `skill-author-orchestrator` (model: opus) via the `Agent` tool
med denne prompten:

```
Source file: <absolute path to source>
Catalog root: ${CLAUDE_PLUGIN_ROOT}/skills/cc-architect-catalog/
Plugin root: ${CLAUDE_PLUGIN_ROOT}
Mode: <default | quick>

Run the full skill-author pipeline:
1. Validate source (you re-validate; trust nothing).
2. Launch concept-extractor (sonnet) with the source path. Parse JSON.
3. If out_of_scope: report and stop.
4. Launch skill-drafter (sonnet) with concept JSON + source path.
5. If too-technical-to-paraphrase: report and stop.
6. If mode != quick: launch ip-hygiene-checker (sonnet) with draft + source.
7. Emit completion summary with verdict, draft path, score, next-step.
```

Foreground execution (no `run_in_background`). Wait for the
orchestrator to complete before continuing.

## Phase 4 — Present summary to user

Når orchestratoren returnerer, presenter et kompakt sammendrag:

```
## Skill-Author Complete

Source:   <source path>
Verdict:  <accepted | needs-review | rejected | out-of-scope | skipped (--quick) | error>
Draft:    <.drafts/<slug>.md | deleted | not-written>
Score:    <ngram_overlap_score | n/a>
Longest:  <longestRun shingle | n/a>

### Next step
<context-specific next step>
```

Next-step-tekstene matcher orchestratorens guidance:

- **accepted** →
  ```
  Review the draft body. If you're happy:
    mv skills/cc-architect-catalog/.drafts/<slug>.md \
       skills/cc-architect-catalog/<slug>.md
  ```
- **needs-review** →
  ```
  Score is in the gray zone (between accepted and rejected). Open the
  draft, compare against the source, decide whether the overlap is
  unavoidable (technical contract) or fixable (rephrase further).
  ```
- **rejected** →
  ```
  Draft was deleted (containment too high or longest verbatim run too
  long). Either rephrase the source by hand and re-run, or pick a
  different source.
  ```
- **out-of-scope** →
  ```
  Source did not map to a fase-1 supported cc_feature/layer combo.
  Reason: <reason from concept-extractor>
  Pick a source that explains how a CC feature works (reference layer)
  or when to reach for it (pattern layer).
  ```
- **skipped (--quick)** →
  ```
  Re-run WITHOUT --quick to score the draft before promotion.
  ```
- **error** →
  ```
  See error above. Common causes: source unreadable, source too large,
  drafter aborted on too-technical-to-paraphrase.
  ```

## Phase 5 — Stats

Append én linje til
`${CLAUDE_PLUGIN_DATA}/ultra-skill-author-local-stats.jsonl`:

```json
{
  "ts": "<ISO-8601>",
  "source": "<source path>",
  "source_size_bytes": <N>,
  "mode": "<default|quick>",
  "verdict": "<accepted|needs-review|rejected|out-of-scope|skipped|error>",
  "cc_feature": "<from concept-extractor or null>",
  "layer": "<reference|pattern|null>",
  "slug": "<computed slug or null>",
  "draft_path": "<.drafts/<slug>.md | null>",
  "ngram_overlap_score": <float | null>,
  "longest_run": <int | null>,
  "deleted": <true|false>
}
```

Hvis `${CLAUDE_PLUGIN_DATA}` ikke er satt eller ikke skrivbar, skip
stats silently.

## Hard rules

- **One source per invocation.** Brukeren passer én sti. Pipelinen
  produserer én draft (eller null på out-of-scope/rejected/error).
- **No automation.** Ingen watcher, ingen batch, ingen retry. Brief
  §Non-Goals er eksplisitt.
- **No catalog-root writes.** Drafts lever i `.drafts/` only.
  Promotion er manuell `mv` av brukeren.
- **No source edits.** Kilden er read-only input.
- **No URL or remote input.** Kun lokale filstier i fase-1 MVP.
- **Foreground only in fase-1.** `--fg` aksepteres som no-op for
  konvensjon; background-modus kommer i fase 2+.
- **Sonnet for sub-agents.** Opus kun for denne kommandoen og
  orchestratoren.
- **Privacy.** Aldri logg kilde-innhold i stats eller summaries.
  Verdikt, scorer og stier er nok.
- **Honesty.** Hvis pipelinen feiler, rapporter eksakt fase og grunn.
  Ikke later som om det gikk bra.
- **--quick warning is mandatory.** Hopper du over IP-hygiene må
  brukeren vite det tydelig — draftet er IKKE klart for promotion.
