@greenrenge/skills 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +99 -2
- package/bin/cli.mjs +525 -0
- package/bin/lib/onboard.mjs +1168 -0
- package/bin/lib/probe.mjs +631 -0
- package/catalog.json +590 -0
- package/package.json +50 -4
- package/skills/deck-story/SKILL.md +258 -0
- package/skills/deck-story/check-svg-text.mjs +94 -0
- package/skills/deck-story/check.mjs +348 -0
- package/skills/diagram-router/LICENSE +21 -0
- package/skills/diagram-router/SKILL.md +193 -0
- package/skills/diagram-router/THIRD_PARTY_NOTICES.md +15 -0
- package/skills/diagram-router/references/channels.md +213 -0
- package/skills/diagram-router/references/evals.md +85 -0
- package/skills/diagram-router/references/gathering.md +101 -0
- package/skills/diagram-router/references/prior-art.md +65 -0
- package/skills/diagram-router/references/routing.md +166 -0
- package/skills/diagram-router/skill-release.json +17 -0
- package/skills/frontend-design/SKILL.md +443 -0
- package/skills/frontend-design/references/rtl.md +72 -0
- package/skills/frontend-design/scripts/.upstream-sha +1 -0
- package/skills/frontend-design/scripts/LICENSE +21 -0
- package/skills/frontend-design/scripts/README.md +24 -0
- package/skills/frontend-design/scripts/gates.md +243 -0
- package/skills/frontend-design/scripts/sloplint-render.mjs +1283 -0
- package/skills/frontend-design/scripts/sloplint.mjs +4426 -0
- package/skills/open-code-review-rules/SKILL.md +59 -0
- package/skills/open-code-review-rules/references/ocr-allowlists.json +161 -0
- package/skills/open-code-review-rules/references/ocr-rule-semantics.md +39 -0
- package/skills/open-code-review-rules/scripts/verify_ocr_rules.py +836 -0
- package/skills/plain-english-mode/SKILL.md +41 -0
- package/skills/pr-diagram-portfolio/SKILL.md +75 -0
- package/skills/pr-diagram-portfolio/references/angle-framework.md +124 -0
- package/skills/pr-diagram-portfolio/references/portfolio-delivery.md +79 -0
- package/skills/pr-diagram-portfolio/scripts/restore_still_css.py +180 -0
- package/skills/pr-lens/LICENSE-upstream +21 -0
- package/skills/pr-lens/SKILL.md +99 -0
- package/skills/pr-lens/VENDOR.md +47 -0
- package/skills/pr-lens/package-lock.json +91 -0
- package/skills/pr-lens/package.json +9 -0
- package/skills/pr-lens/references/config.md +90 -0
- package/skills/pr-lens/references/example.graph.json +580 -0
- package/skills/pr-lens/references/graph-document.md +233 -0
- package/skills/pr-lens/skill-release.json +16 -0
- package/skills/security-remediation-epic/SKILL.md +316 -0
- package/skills/security-remediation-epic/prompt-template.md +33 -0
- package/skills/skill-maintainer/SKILL.md +99 -0
- package/skills/skill-maintainer/references/placement-and-coupling.md +43 -0
- package/skills/skill-maintainer/scripts/audit_skills.py +297 -0
- package/skills/t3-successor-handoff/SKILL.md +141 -0
- package/skills/t3-thread-bridge/SKILL.md +175 -0
- package/skills/t3-thread-bridge/references/launch-recipes.md +123 -0
- package/skills/t3-thread-bridge/references/ping-back.md +108 -0
- package/skills/t3-thread-bridge/scripts/thread_ledger.py +203 -0
- package/skills/t3-ticket-orchestrator/SKILL.md +304 -0
- package/skills/t3-ticket-orchestrator/references/proving-the-gates.md +63 -0
- package/skills/ticket-scheme/SKILL.md +144 -0
- package/skills/ulw-plan/SKILL.md +98 -0
- package/skills/ulw-plan/references/full-workflow.md +255 -0
- package/skills/ulw-plan/references/intent-clear.md +44 -0
- package/skills/ulw-plan/references/intent-unclear.md +44 -0
- package/skills/ulw-plan/scripts/plan-templates.mjs +180 -0
- package/skills/ulw-plan/scripts/scaffold-plan.mjs +187 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-maintainer
|
|
3
|
+
description: >
|
|
4
|
+
Create, edit, update, fix, modify, refactor, decouple, audit, compose, opt-in,
|
|
5
|
+
rename, or remove any agent skill (SKILL.md) or host rule in dot-env or project
|
|
6
|
+
repositories using skillfold. ALWAYS use before creating, editing, updating, or
|
|
7
|
+
maintaining any skill — whether adding a new skill, tweaking an existing SKILL.md,
|
|
8
|
+
deciding host vs repo placement, enabling opt-in skill bundles, auditing for
|
|
9
|
+
hardcoded paths/coupling/shadowing, or updating agents/skillfold.yaml safely.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Skill Maintainer
|
|
13
|
+
|
|
14
|
+
Maintain agent skills as clean, decoupled, lockfile-verified packages managed by
|
|
15
|
+
`skillfold`. Read [`references/placement-and-coupling.md`](references/placement-and-coupling.md)
|
|
16
|
+
before moving skills between host and repo scope or designing a composed skill.
|
|
17
|
+
|
|
18
|
+
## 1. Decide placement first
|
|
19
|
+
|
|
20
|
+
Place every skill in exactly **one** canonical home:
|
|
21
|
+
|
|
22
|
+
| Skill nature | Canonical home | Enabled by default? |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| Portable across repos & machines (workflows, diagrams, code review, meta) | `dot-env/agents/catalog/<group>/` | Yes (`agents/skillfold.yaml`) |
|
|
25
|
+
| Machine operations on this host (backups, docker, gateways, publishing) | `dot-env/agents/catalog/host-ops/` | Yes (`agents/skillfold.yaml`) |
|
|
26
|
+
| Machine × repo adapter (how a specific repo runs on this specific host) | `dot-env/agents/catalog/host-adapters/` | Yes (`agents/skillfold.yaml`) |
|
|
27
|
+
| Stack-specific host catalog (Cloudflare, frontend/web UI, etc.) | `dot-env/agents/catalog/opt-in-<stack>/` | **No** — opted in per project |
|
|
28
|
+
| Team/repo domain workflow (shared by all contributors on any OS) | `<repo>/.claude/skills/` (or `<repo>/skillfold.yaml`) | Repo-scoped |
|
|
29
|
+
|
|
30
|
+
**Anti-shadowing rule:** Never keep a second copy of a host-installed skill inside a
|
|
31
|
+
project repo. User/host skills outrank or duplicate project skills in Claude Code and
|
|
32
|
+
other harnesses, causing silent drift.
|
|
33
|
+
|
|
34
|
+
## 2. Decoupling rules
|
|
35
|
+
|
|
36
|
+
Every skill edit must pass these checks before commit:
|
|
37
|
+
|
|
38
|
+
1. **No personal paths or machine constants in portable skills.** Never write
|
|
39
|
+
`/home/<user>/...`, `/var/home/<user>/...`, hostnames, or tailnet IPs inside
|
|
40
|
+
portable groups (`meta`, `core-workflow`, `diagrams`, `t3-orchestration`, `opt-in-*`).
|
|
41
|
+
Use relative paths from the skill directory, `$HOME`, or reference the host profile
|
|
42
|
+
rule (`~/.agents/rules/host-<host>.md`).
|
|
43
|
+
2. **Invert repo dependencies.** Orchestrators and generic workflows must not hardcode
|
|
44
|
+
one repository's scripts, flags, or repo-only skill names. Define an explicit
|
|
45
|
+
*Run Contract* table whose values are supplied by the invoking prompt or repo config.
|
|
46
|
+
3. **Acyclic graph.** Never allow circular `dependsOn` metadata or `compose:` loops.
|
|
47
|
+
Leaf renderers/tools do not depend back on routers.
|
|
48
|
+
4. **Isolate harness tools.** Harness-specific MCP tools (e.g. T3 Code `watch_pull_request`,
|
|
49
|
+
`html_preview`/`html_render`, `t3_thread_*`) belong in a clearly marked *Harness
|
|
50
|
+
adapter* section with a plain fallback when running in another harness.
|
|
51
|
+
|
|
52
|
+
## 3. Safe `dot-env` edit workflow (zero live impact)
|
|
53
|
+
|
|
54
|
+
`~/.agents/skills` and every consumer directory symlink directly into `dot-env/agents/skills/`.
|
|
55
|
+
**Never refactor on live `main`.**
|
|
56
|
+
|
|
57
|
+
1. **Create an isolated worktree:**
|
|
58
|
+
```bash
|
|
59
|
+
git -C ~/.t3/projects/dot-env worktree add -b <branch> ~/.t3/worktrees/dot-env/<slug> main
|
|
60
|
+
```
|
|
61
|
+
2. **Edit canonical sources only:** Edit under `agents/catalog/<group>/<skill>/`,
|
|
62
|
+
`agents/rule-sources/`, or `agents/skillfold.yaml`. Never hand-edit generated files
|
|
63
|
+
under `agents/skills/` or `agents/rules/`.
|
|
64
|
+
3. **Materialize and lock:**
|
|
65
|
+
```bash
|
|
66
|
+
npx skillfold install --dir agents
|
|
67
|
+
npx skillfold check --dir agents
|
|
68
|
+
```
|
|
69
|
+
4. **Run the skill linter (from the worktree root):**
|
|
70
|
+
```bash
|
|
71
|
+
python3 agents/catalog/meta/skill-maintainer/scripts/audit_skills.py --agents-dir agents [--project-skills /path/to/repo/.claude/skills] --strict
|
|
72
|
+
```
|
|
73
|
+
5. **Check repo hooks:**
|
|
74
|
+
- If you moved or renamed a skill whose binary is linked by Ansible (e.g.
|
|
75
|
+
`publish-app-cloudflare/bin/cf-serve`), verify `ansible/playbooks/tasks/skills.yml`.
|
|
76
|
+
- If a skill ships `vendor/` directories (e.g. `archify`), verify `.gitignore`
|
|
77
|
+
unignores both `agents/catalog/.../vendor/` and `agents/skills/.../vendor/`.
|
|
78
|
+
- Confirm nothing `git check-ignore` flags is staged before committing.
|
|
79
|
+
6. **Review, merge to `main`, and remove the worktree** when ready.
|
|
80
|
+
|
|
81
|
+
## 4. Common `skillfold` operations
|
|
82
|
+
|
|
83
|
+
- **Add a new local host skill:** Create `agents/catalog/<group>/<name>/SKILL.md`,
|
|
84
|
+
add `<name>: ./catalog/<group>/<name>` to `agents/skillfold.yaml`, then run
|
|
85
|
+
`npx skillfold install --dir agents && npx skillfold check --dir agents`.
|
|
86
|
+
- **Opt a project into optional host skills** (e.g. Cloudflare or Web UI): In the
|
|
87
|
+
project's own `skillfold.yaml`, point at the catalog entry (local path or pinned
|
|
88
|
+
`github:` ref) and run `npx skillfold install`:
|
|
89
|
+
```yaml
|
|
90
|
+
targets: [claude, codex]
|
|
91
|
+
skills:
|
|
92
|
+
frontend-design: github:<owner>/dot-env/agents/catalog/opt-in-web-ui/frontend-design@main
|
|
93
|
+
```
|
|
94
|
+
- **Compose a workflow skill:** Use `compose:` in `skillfold.yaml` (`use: [a, b]`)
|
|
95
|
+
when two skills must execute as one unified procedure; `skillfold` unions
|
|
96
|
+
`allowed-tools`, carries supporting files, rejects cycles, and hashes the output.
|
|
97
|
+
- **Deprecate or rename a skill:** Remove the old key from `agents/skillfold.yaml`,
|
|
98
|
+
add the new key, run `npx skillfold install --dir agents` (`skillfold` prunes only
|
|
99
|
+
lockfile-managed directories), and grep the repo for stale references.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Skill Placement & Decoupling Reference
|
|
2
|
+
|
|
3
|
+
## Catalog Group Taxonomy (`dot-env/agents/catalog/`)
|
|
4
|
+
|
|
5
|
+
| Group | Enabled globally? | Scope & Portability contract |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `meta` | Yes | Skill lifecycle & authoring tools (`skill-maintainer`). Portable. |
|
|
8
|
+
| `core-workflow` | Yes | General dev workflows (`ulw-plan`, `plain-english-mode`, `open-code-review*`). Portable. |
|
|
9
|
+
| `diagrams` | Yes | Canonical visual & deck suite (`diagram-router`, `pr-lens`, `archify`, `diagram-design`, `stack-diagram`, `pr-diagram-portfolio`, `deck-story`). Portable; machine rendering hints live in host profile rule. |
|
|
10
|
+
| `t3-orchestration` | Yes | Multi-thread orchestration, handoff, & remediation workflows. Repo-agnostic; repo specifics injected via Run Contract. |
|
|
11
|
+
| `host-ops` | Yes | Operations specific to this host (`system-backup`, `docker-teardown`, `tmp-scratch`, `llm-gateway`, `publish-app-*`, `cleanup-published-app-*`). Reads shared facts from host profile rule. |
|
|
12
|
+
| `host-adapters` | Yes | Machine × repo glue (e.g. `<repo>-dev-env`, `<repo>-evidence`) encoding how a specific repo runs on this host without polluting the shared repo for teammates. |
|
|
13
|
+
| `opt-in-web-ui` | No | Opt-in frontend & modern web skills (`frontend-design`, `modern-web-guidance`). Enabled per project via `skillfold.yaml`. |
|
|
14
|
+
| `opt-in-cloudflare` | No | Opt-in Cloudflare Workers/Pages/CLI skills (8 skills). Enabled per project via `skillfold.yaml`. |
|
|
15
|
+
|
|
16
|
+
## Scope Precedence & Shadowing
|
|
17
|
+
|
|
18
|
+
- In Claude Code and similar harnesses, **user/host skills outrank or duplicate
|
|
19
|
+
project-level skills with the same name**.
|
|
20
|
+
- Keep a skill in **either** host (`dot-env`) **or** project (`.claude/skills`),
|
|
21
|
+
never both.
|
|
22
|
+
- Run `audit_skills.py --agents-dir agents --project-skills <repo>/.claude/skills`
|
|
23
|
+
whenever onboarding a repository to catch shadowing immediately.
|
|
24
|
+
|
|
25
|
+
## The Six Coupling Anti-Patterns
|
|
26
|
+
|
|
27
|
+
1. **Host → Repo bleed**: A global orchestrator hardcodes one repo's bootstrap script,
|
|
28
|
+
env flags, or repo-only skill names.
|
|
29
|
+
- *Fix*: Define a Run Contract section; pass repo-specific values from the invoking prompt.
|
|
30
|
+
2. **Repo → Host duplication**: Vendoring snapshots of host skills inside a repo.
|
|
31
|
+
- *Fix*: Keep one canonical copy (host for cross-repo tools like diagrams; repo for
|
|
32
|
+
team-shared domain rules).
|
|
33
|
+
3. **Hardcoded machine/user identity**: Embedding `/home/<user>/...`, `/var/home/<user>/...`,
|
|
34
|
+
hostnames, or IPs in portable skills or scripts.
|
|
35
|
+
- *Fix*: Use relative skill paths, `$HOME`, and `agents/rule-sources/host-<name>.md`.
|
|
36
|
+
4. **Harness lock-in**: Requiring T3-only or Claude-only MCP tools in otherwise generic
|
|
37
|
+
workflows without a fallback.
|
|
38
|
+
- *Fix*: Separate core methodology from an explicit *Harness adapter* block.
|
|
39
|
+
5. **Circular references**: Router → renderer AND renderer `dependsOn: [router]`.
|
|
40
|
+
- *Fix*: Enforce a strict DAG: routers reference renderers; renderers stay self-contained.
|
|
41
|
+
6. **Flat global context tax**: Installing niche stack skills (Cloudflare, framework
|
|
42
|
+
guides) globally into every unrelated session.
|
|
43
|
+
- *Fix*: Move niche stacks to `catalog/opt-in-*` and opt in per project via `skillfold`.
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Audit dot-env agent skills for frontmatter, coupling, cycles, and shadowing."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import re
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
PORTABLE_GROUPS = {
|
|
14
|
+
"meta",
|
|
15
|
+
"core-workflow",
|
|
16
|
+
"diagrams",
|
|
17
|
+
"t3-orchestration",
|
|
18
|
+
"opt-in-web-ui",
|
|
19
|
+
"opt-in-cloudflare",
|
|
20
|
+
}
|
|
21
|
+
HOST_GROUPS = {"host-ops", "host-adapters"}
|
|
22
|
+
|
|
23
|
+
NAME_RE = re.compile(r"^[a-z0-9][a-z0-9-]{0,63}$")
|
|
24
|
+
ABS_USER_PATH_RE = re.compile(r"/(?:var/)?home/(?!linuxbrew/|\.snapshots/)[a-zA-Z0-9._-]+/")
|
|
25
|
+
HOST_IDENTITY_RE = re.compile(r"\b(?:100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7])\.\d{1,3}\.\d{1,3}|[a-z0-9-]+\.[a-z0-9-]+\.ts\.net)\b")
|
|
26
|
+
SCAN_EXTS = {".md", ".py", ".sh", ".json", ".yaml", ".yml"}
|
|
27
|
+
SKIP_DIRS = {"vendor", "node_modules", "__pycache__", ".git", ".venv"}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def parse_frontmatter(skill_md: Path) -> tuple[dict[str, str], list[str]]:
|
|
31
|
+
errors: list[str] = []
|
|
32
|
+
text = skill_md.read_text(encoding="utf-8", errors="replace")
|
|
33
|
+
if not text.startswith("---"):
|
|
34
|
+
return {}, ["missing YAML frontmatter opening '---'"]
|
|
35
|
+
lines = text.splitlines()
|
|
36
|
+
end_idx = None
|
|
37
|
+
for i in range(1, len(lines)):
|
|
38
|
+
if lines[i].strip() == "---":
|
|
39
|
+
end_idx = i
|
|
40
|
+
break
|
|
41
|
+
if end_idx is None:
|
|
42
|
+
return {}, ["unterminated YAML frontmatter"]
|
|
43
|
+
|
|
44
|
+
meta: dict[str, str] = {}
|
|
45
|
+
current_key: str | None = None
|
|
46
|
+
buf: list[str] = []
|
|
47
|
+
for line in lines[1:end_idx]:
|
|
48
|
+
if re.match(r"^[a-zA-Z0-9_-]+\s*:", line):
|
|
49
|
+
if current_key is not None:
|
|
50
|
+
meta[current_key] = " ".join(x.strip() for x in buf if x.strip()).strip()
|
|
51
|
+
k, v = line.split(":", 1)
|
|
52
|
+
current_key = k.strip()
|
|
53
|
+
v = v.strip()
|
|
54
|
+
if v in {">", "|", ">-", "|-"}:
|
|
55
|
+
buf = []
|
|
56
|
+
else:
|
|
57
|
+
buf = [v.strip('"').strip("'")]
|
|
58
|
+
elif current_key is not None and (line.startswith(" ") or line.startswith("\t")):
|
|
59
|
+
buf.append(line.strip())
|
|
60
|
+
if current_key is not None:
|
|
61
|
+
meta[current_key] = " ".join(x.strip() for x in buf if x.strip()).strip()
|
|
62
|
+
return meta, errors
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def parse_skillfold_yaml(path: Path) -> tuple[dict[str, str], dict[str, str]]:
|
|
66
|
+
"""Minimal parser for local skill/rule mappings in agents/skillfold.yaml."""
|
|
67
|
+
skills: dict[str, str] = {}
|
|
68
|
+
rules: dict[str, str] = {}
|
|
69
|
+
if not path.exists():
|
|
70
|
+
return skills, rules
|
|
71
|
+
|
|
72
|
+
section: str | None = None
|
|
73
|
+
current_name: str | None = None
|
|
74
|
+
for raw in path.read_text(encoding="utf-8").splitlines():
|
|
75
|
+
line = raw.split("#", 1)[0].rstrip()
|
|
76
|
+
if not line.strip():
|
|
77
|
+
continue
|
|
78
|
+
if not raw.startswith((" ", "\t")):
|
|
79
|
+
key = line.split(":", 1)[0].strip()
|
|
80
|
+
section = key if key in {"skills", "rules", "compose"} else None
|
|
81
|
+
current_name = None
|
|
82
|
+
continue
|
|
83
|
+
if section in {"skills", "rules"}:
|
|
84
|
+
m = re.match(r"^ ([a-z0-9-]+):\s*(.*)$", line)
|
|
85
|
+
if m:
|
|
86
|
+
current_name = m.group(1)
|
|
87
|
+
val = m.group(2).strip().strip('"').strip("'")
|
|
88
|
+
if val:
|
|
89
|
+
(skills if section == "skills" else rules)[current_name] = val
|
|
90
|
+
continue
|
|
91
|
+
m_src = re.match(r"^ source:\s*(.+)$", line)
|
|
92
|
+
if m_src and current_name:
|
|
93
|
+
val = m_src.group(1).strip().strip('"').strip("'")
|
|
94
|
+
(skills if section == "skills" else rules)[current_name] = val
|
|
95
|
+
return skills, rules
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def detect_cycles(graph: dict[str, list[str]]) -> list[list[str]]:
|
|
99
|
+
cycles: list[list[str]] = []
|
|
100
|
+
visiting: list[str] = []
|
|
101
|
+
visited: set[str] = set()
|
|
102
|
+
|
|
103
|
+
def dfs(node: str) -> None:
|
|
104
|
+
if node in visiting:
|
|
105
|
+
idx = visiting.index(node)
|
|
106
|
+
cycles.append(visiting[idx:] + [node])
|
|
107
|
+
return
|
|
108
|
+
if node in visited:
|
|
109
|
+
return
|
|
110
|
+
visiting.append(node)
|
|
111
|
+
for nxt in graph.get(node, []):
|
|
112
|
+
if nxt in graph:
|
|
113
|
+
dfs(nxt)
|
|
114
|
+
visiting.pop()
|
|
115
|
+
visited.add(node)
|
|
116
|
+
|
|
117
|
+
for n in sorted(graph):
|
|
118
|
+
dfs(n)
|
|
119
|
+
return cycles
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def audit(agents_dir: Path, project_skills_dir: Path | None) -> dict[str, Any]:
|
|
123
|
+
findings: list[dict[str, str]] = []
|
|
124
|
+
catalog_dir = agents_dir / "catalog"
|
|
125
|
+
manifest_path = agents_dir / "skillfold.yaml"
|
|
126
|
+
skills_out_dir = agents_dir / "skills"
|
|
127
|
+
|
|
128
|
+
def add(severity: str, code: str, target: str, message: str) -> None:
|
|
129
|
+
findings.append({
|
|
130
|
+
"severity": severity,
|
|
131
|
+
"code": code,
|
|
132
|
+
"target": target,
|
|
133
|
+
"message": message,
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
if not catalog_dir.is_dir():
|
|
137
|
+
add("error", "missing_catalog", str(catalog_dir), "agents/catalog/ directory not found")
|
|
138
|
+
return {"findings": findings, "catalog_count": 0, "enabled_count": 0}
|
|
139
|
+
|
|
140
|
+
manifest_skills, manifest_rules = parse_skillfold_yaml(manifest_path)
|
|
141
|
+
if not manifest_path.exists():
|
|
142
|
+
add("error", "missing_manifest", str(manifest_path), "agents/skillfold.yaml not found")
|
|
143
|
+
|
|
144
|
+
catalog_skills: dict[str, tuple[str, Path]] = {}
|
|
145
|
+
dep_graph: dict[str, list[str]] = {}
|
|
146
|
+
|
|
147
|
+
for group_dir in sorted(p for p in catalog_dir.iterdir() if p.is_dir()):
|
|
148
|
+
group = group_dir.name
|
|
149
|
+
for skill_dir in sorted(p for p in group_dir.iterdir() if p.is_dir()):
|
|
150
|
+
skill_name = skill_dir.name
|
|
151
|
+
rel = f"catalog/{group}/{skill_name}"
|
|
152
|
+
if skill_name in catalog_skills:
|
|
153
|
+
add("error", "duplicate_catalog_skill", rel, f"duplicate skill name '{skill_name}'")
|
|
154
|
+
catalog_skills[skill_name] = (group, skill_dir)
|
|
155
|
+
dep_graph.setdefault(skill_name, [])
|
|
156
|
+
|
|
157
|
+
if not NAME_RE.match(skill_name):
|
|
158
|
+
add("error", "invalid_skill_name", rel, "directory name must match ^[a-z0-9][a-z0-9-]{0,63}$")
|
|
159
|
+
|
|
160
|
+
skill_md = skill_dir / "SKILL.md"
|
|
161
|
+
if not skill_md.is_file():
|
|
162
|
+
add("error", "missing_skill_md", rel, "SKILL.md is missing")
|
|
163
|
+
continue
|
|
164
|
+
|
|
165
|
+
meta, fm_errs = parse_frontmatter(skill_md)
|
|
166
|
+
for err in fm_errs:
|
|
167
|
+
add("error", "bad_frontmatter", rel, err)
|
|
168
|
+
if not fm_errs:
|
|
169
|
+
fm_name = meta.get("name", "")
|
|
170
|
+
fm_desc = meta.get("description", "")
|
|
171
|
+
if not fm_name:
|
|
172
|
+
add("error", "missing_name", rel, "frontmatter 'name' is missing")
|
|
173
|
+
elif fm_name.lower().replace(" ", "-") != skill_name and fm_name != skill_name:
|
|
174
|
+
# Allow human-readable title only as warning if skillfold rewrites it
|
|
175
|
+
add("warning", "name_mismatch", rel, f"frontmatter name '{fm_name}' != dir '{skill_name}'")
|
|
176
|
+
if not fm_desc:
|
|
177
|
+
add("error", "missing_description", rel, "frontmatter 'description' is empty")
|
|
178
|
+
|
|
179
|
+
# Check dependsOn metadata if present
|
|
180
|
+
release_json = skill_dir / "skill-release.json"
|
|
181
|
+
if release_json.is_file():
|
|
182
|
+
try:
|
|
183
|
+
data = json.loads(release_json.read_text(encoding="utf-8"))
|
|
184
|
+
deps = data.get("dependsOn") or []
|
|
185
|
+
if isinstance(deps, list):
|
|
186
|
+
dep_graph[skill_name] = [str(d) for d in deps]
|
|
187
|
+
except json.JSONDecodeError as exc:
|
|
188
|
+
add("error", "invalid_release_json", f"{rel}/skill-release.json", str(exc))
|
|
189
|
+
|
|
190
|
+
# Scan text files for hardcoded user paths and host identity leakage
|
|
191
|
+
for fpath in skill_dir.rglob("*"):
|
|
192
|
+
if any(part in SKIP_DIRS for part in fpath.parts):
|
|
193
|
+
continue
|
|
194
|
+
if not fpath.is_file() or fpath.suffix not in SCAN_EXTS:
|
|
195
|
+
continue
|
|
196
|
+
if fpath.name == "audit_skills.py":
|
|
197
|
+
continue
|
|
198
|
+
content = fpath.read_text(encoding="utf-8", errors="replace")
|
|
199
|
+
frel = str(fpath.relative_to(agents_dir))
|
|
200
|
+
for lineno, line in enumerate(content.splitlines(), 1):
|
|
201
|
+
if ABS_USER_PATH_RE.search(line):
|
|
202
|
+
# system-layout.md documents the machine's mount layout intentionally
|
|
203
|
+
if fpath.name == "system-layout.md" and group in HOST_GROUPS:
|
|
204
|
+
continue
|
|
205
|
+
add(
|
|
206
|
+
"error" if group in PORTABLE_GROUPS else "warning",
|
|
207
|
+
"hardcoded_user_path",
|
|
208
|
+
f"{frel}:{lineno}",
|
|
209
|
+
f"hardcoded user path found: {line.strip()[:100]}",
|
|
210
|
+
)
|
|
211
|
+
if group in PORTABLE_GROUPS and HOST_IDENTITY_RE.search(line):
|
|
212
|
+
add(
|
|
213
|
+
"error",
|
|
214
|
+
"host_identity_in_portable_skill",
|
|
215
|
+
f"{frel}:{lineno}",
|
|
216
|
+
f"host-specific identity in portable group '{group}': {line.strip()[:100]}",
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
# Check dependency cycles and unknown dependencies
|
|
220
|
+
for name, deps in dep_graph.items():
|
|
221
|
+
for d in deps:
|
|
222
|
+
if d not in catalog_skills:
|
|
223
|
+
add("warning", "unknown_dependency", name, f"dependsOn '{d}' not found in catalog")
|
|
224
|
+
for cycle in detect_cycles(dep_graph):
|
|
225
|
+
add("error", "dependency_cycle", " -> ".join(cycle), "circular dependsOn detected")
|
|
226
|
+
|
|
227
|
+
# Verify manifest coverage and local paths
|
|
228
|
+
for name, src in manifest_skills.items():
|
|
229
|
+
if src.startswith("./"):
|
|
230
|
+
target = (agents_dir / src).resolve()
|
|
231
|
+
if not (target / "SKILL.md").is_file():
|
|
232
|
+
add("error", "broken_manifest_skill", f"skillfold.yaml:{name}", f"missing SKILL.md at {src}")
|
|
233
|
+
for name, src in manifest_rules.items():
|
|
234
|
+
if src.startswith("./"):
|
|
235
|
+
target = (agents_dir / src).resolve()
|
|
236
|
+
if not target.is_file():
|
|
237
|
+
add("error", "broken_manifest_rule", f"skillfold.yaml:{name}", f"missing rule file at {src}")
|
|
238
|
+
|
|
239
|
+
for name, (group, _) in catalog_skills.items():
|
|
240
|
+
is_opt_in = group.startswith("opt-in-")
|
|
241
|
+
if not is_opt_in and name not in manifest_skills:
|
|
242
|
+
add("warning", "unregistered_catalog_skill", f"catalog/{group}/{name}", "non-opt-in skill not declared in skillfold.yaml")
|
|
243
|
+
if is_opt_in and name in manifest_skills:
|
|
244
|
+
add("warning", "opt_in_enabled_globally", f"catalog/{group}/{name}", "opt-in skill is enabled in global skillfold.yaml")
|
|
245
|
+
|
|
246
|
+
# Check host vs project shadowing
|
|
247
|
+
if project_skills_dir is not None and project_skills_dir.is_dir():
|
|
248
|
+
active_host = set(manifest_skills.keys())
|
|
249
|
+
if skills_out_dir.is_dir():
|
|
250
|
+
active_host |= {p.name for p in skills_out_dir.iterdir() if p.is_dir()}
|
|
251
|
+
for p in sorted(project_skills_dir.iterdir()):
|
|
252
|
+
if p.is_dir() and p.name in active_host:
|
|
253
|
+
add(
|
|
254
|
+
"warning",
|
|
255
|
+
"host_shadows_project",
|
|
256
|
+
p.name,
|
|
257
|
+
f"host skill '{p.name}' shadows project skill at {p}",
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
"findings": findings,
|
|
262
|
+
"catalog_count": len(catalog_skills),
|
|
263
|
+
"enabled_count": len(manifest_skills),
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def main() -> int:
|
|
268
|
+
parser = argparse.ArgumentParser(description="Audit agent skills catalog and skillfold manifest.")
|
|
269
|
+
parser.add_argument("--agents-dir", default="agents", help="Path to dot-env agents/ directory")
|
|
270
|
+
parser.add_argument("--project-skills", default=None, help="Optional project .claude/skills path for shadowing check")
|
|
271
|
+
parser.add_argument("--strict", action="store_true", help="Exit nonzero on warnings as well as errors")
|
|
272
|
+
parser.add_argument("--json", action="store_true", help="Emit JSON output")
|
|
273
|
+
args = parser.parse_args()
|
|
274
|
+
|
|
275
|
+
result = audit(
|
|
276
|
+
Path(args.agents_dir).resolve(),
|
|
277
|
+
Path(args.project_skills).resolve() if args.project_skills else None,
|
|
278
|
+
)
|
|
279
|
+
findings = result["findings"]
|
|
280
|
+
errors = [f for f in findings if f["severity"] == "error"]
|
|
281
|
+
warnings = [f for f in findings if f["severity"] == "warning"]
|
|
282
|
+
|
|
283
|
+
if args.json:
|
|
284
|
+
print(json.dumps(result, indent=2))
|
|
285
|
+
else:
|
|
286
|
+
print(f"Catalog skills: {result['catalog_count']} | Enabled globally: {result['enabled_count']}")
|
|
287
|
+
print(f"Errors: {len(errors)} | Warnings: {len(warnings)}")
|
|
288
|
+
for f in findings:
|
|
289
|
+
print(f"[{f['severity'].upper()}] {f['code']} ({f['target']}): {f['message']}")
|
|
290
|
+
|
|
291
|
+
if errors or (args.strict and warnings):
|
|
292
|
+
return 1
|
|
293
|
+
return 0
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
if __name__ == "__main__":
|
|
297
|
+
sys.exit(main())
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: t3-successor-handoff
|
|
3
|
+
description: Hand an ending T3 thread's run to a successor thread — handoff doc(s) written with the repo's then the host's handoff skills, what carries collected (the ancestor's thread id, environment id and every linked or watched PR), the successor launched top-level with the templated brief, and the handback gated on the successor's verified state summary. Use when the user says successor, spawn my successor, hand over or hand off the thread, or settle its open questions — or a thread is ending while it still watches PRs. T3 threads only; a session-to-session handover runs the handoff skills alone.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hand the thread to its successor
|
|
7
|
+
|
|
8
|
+
The succession's shape: **you** are the **ancestor** — the thread ending its run
|
|
9
|
+
— and a fresh top-level thread, the **successor**, takes the work over. The
|
|
10
|
+
words that carry the recipe:
|
|
11
|
+
|
|
12
|
+
- **carries** — what moves to the successor: the handoff doc(s), your own
|
|
13
|
+
thread id (its ping-back target), and every PR you link or watch.
|
|
14
|
+
- **settle** — how questions die: the successor sends them to you, the user
|
|
15
|
+
settles them in your chat, you relay the answer.
|
|
16
|
+
- **state summary** — the successor's short replay of what it now holds; the
|
|
17
|
+
handback waits on it and nothing earlier.
|
|
18
|
+
|
|
19
|
+
This is T3-thread-to-T3-thread succession. A plain session-to-session handover
|
|
20
|
+
— no T3 threads in play — runs the discovered handoff skills (step 1) and stops
|
|
21
|
+
there.
|
|
22
|
+
|
|
23
|
+
## The succession
|
|
24
|
+
|
|
25
|
+
1. **Write the handoff(s).** Discover the handoff skills before writing a
|
|
26
|
+
word: the current repo's skills first (for example, a repo's
|
|
27
|
+
`.claude/skills/handoff`), then the host tree (`~/.agents/skills/`).
|
|
28
|
+
Several apply — write one per scope: the repo handoff carries the work, a
|
|
29
|
+
host handoff carries host facts. **One document per scope, even when a scope
|
|
30
|
+
has no skill of its own**: the scope without a skill still gets a document,
|
|
31
|
+
written to the same rules. None discovered at all — write to the core
|
|
32
|
+
rules: for a fresh agent with none of your context; under the OS temp
|
|
33
|
+
dir, outside the workspace; a suggested-skills section naming what the
|
|
34
|
+
successor loads; artifacts referenced by path or URL, duplicated nowhere;
|
|
35
|
+
secrets redacted. Done when every doc exists at a path the successor can
|
|
36
|
+
read.
|
|
37
|
+
|
|
38
|
+
2. **Collect what carries.** `t3_thread_list` → your `currentThreadId` — the
|
|
39
|
+
successor's ping-back target. `t3_environment_links()` → your
|
|
40
|
+
`environmentId`, which `t3_thread_launch`'s `delegatedFrom` requires and
|
|
41
|
+
no other call hands you. `list_thread_pull_requests` → every PR's
|
|
42
|
+
number, url, and `watching`. Done when all three live in the brief's
|
|
43
|
+
holes; anything carried only in your head is lost at handback.
|
|
44
|
+
|
|
45
|
+
3. **Launch the successor.** `t3_thread_launch`, top-level: a readable
|
|
46
|
+
title, the brief below with its holes filled, model and modes inherited
|
|
47
|
+
by omitting them. End your turn after the launch — the successor's sends
|
|
48
|
+
wake you. Done when the launch returns a `threadId` and the thread list
|
|
49
|
+
shows the successor.
|
|
50
|
+
|
|
51
|
+
The `workspaceStrategy` depends on where the work already lives:
|
|
52
|
+
|
|
53
|
+
- `root` — the project checkout. The default.
|
|
54
|
+
- `worktree` — a **new** checkout from `baseRef`. For work that wants its
|
|
55
|
+
own branch and its own checkout.
|
|
56
|
+
- `existing_worktree` — bind `worktreePath`, a project worktree that
|
|
57
|
+
already exists. **The right choice when the work already lives in a
|
|
58
|
+
worktree**: a new `worktree` strategy cannot take a branch another
|
|
59
|
+
worktree already holds, so it would land the successor on a fresh branch
|
|
60
|
+
with none of the commits.
|
|
61
|
+
|
|
62
|
+
4. **Babysit until shared understanding.** The successor takes over the
|
|
63
|
+
PRs, then sends its questions (`t3_thread_send`, your threadId, mode
|
|
64
|
+
`auto`). The user settles them in your chat; relay each settled answer
|
|
65
|
+
the same way — `t3_thread_send`, mode `auto`, or `steer` while it is
|
|
66
|
+
mid-turn. The gate is the successor's state summary: the PRs it now
|
|
67
|
+
watches, their head shas, the open threads, its first intended action.
|
|
68
|
+
Verify it against your own records and correct what is wrong until it
|
|
69
|
+
replays clean. Done when every carried PR is watched by the successor,
|
|
70
|
+
the shas match, and the first action is one you would endorse.
|
|
71
|
+
|
|
72
|
+
**A relay that changes a standing instruction states the delta.** When the
|
|
73
|
+
settled answer differs from what the handoff recorded, say what changed
|
|
74
|
+
*and what it does not authorise*. "Push the branch" read as "push and open
|
|
75
|
+
a PR" is the standing failure here: name the PR as not authorised, and say
|
|
76
|
+
not to ask again.
|
|
77
|
+
|
|
78
|
+
5. **Hand back clean.** The summary holds — that is your confirmation the
|
|
79
|
+
successor holds every carried object. `unwatch_pull_request` each PR you
|
|
80
|
+
still watch: the call itself verifies, and `wasWatching: false` means the
|
|
81
|
+
watch already moved — clean, not an error. When you watch none, there is
|
|
82
|
+
nothing to call and the step is a statement, not a call.
|
|
83
|
+
|
|
84
|
+
**Then settle this thread**: `t3_thread_organize`, `action: "settle"`,
|
|
85
|
+
`threadId` your own. A successor that has everything does not need its
|
|
86
|
+
ancestor still awake, and an unsettled ancestor keeps waking on every
|
|
87
|
+
later send. Settle after the summary verifies, never before.
|
|
88
|
+
|
|
89
|
+
Then tell the user who holds what: the successor's `link`, the PRs it
|
|
90
|
+
watches, what you released, and that this thread is settled. Ending your
|
|
91
|
+
run closes nothing — the successor's later sends still wake you, and
|
|
92
|
+
settling is what makes that harmless. Done when you watch no PR, the
|
|
93
|
+
successor holds everything carried, this thread is settled, and the user
|
|
94
|
+
holds the successor's link.
|
|
95
|
+
|
|
96
|
+
## The successor brief
|
|
97
|
+
|
|
98
|
+
Fill the holes; ship it as the launch `message`, otherwise untouched.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
You are the successor of thread <ancestor-thread-id> — its run is yours now.
|
|
102
|
+
Read <handoff doc paths> first and adopt them as your starting state; they
|
|
103
|
+
name the workspace and branch facts: <the checkout and branch, or the
|
|
104
|
+
worktree and its base when the work needs one>.
|
|
105
|
+
|
|
106
|
+
Before any work:
|
|
107
|
+
|
|
108
|
+
1. Take over every carried PR from your own session — link_pull_request each,
|
|
109
|
+
and watch_pull_request each PR the ancestor watched (<carried PRs: number,
|
|
110
|
+
url, watched>): a watch dies with the session that made it, and only an
|
|
111
|
+
open PR can be watched.
|
|
112
|
+
2. Send your questions to the ancestor — t3_thread_send, threadId
|
|
113
|
+
<ancestor-thread-id>, mode auto — everything the handoff leaves unclear,
|
|
114
|
+
in one message. Then wait: the user settles them, and the settled answers
|
|
115
|
+
arrive the same way.
|
|
116
|
+
|
|
117
|
+
Questions settled, send the ancestor your state summary — the same
|
|
118
|
+
t3_thread_send — one short message: the PRs you now watch, their head shas,
|
|
119
|
+
the open threads, your first intended action. The ancestor verifies it before
|
|
120
|
+
it ends and corrects you where it must. The run is yours when the summary
|
|
121
|
+
holds; begin with the first intended action.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The carried-PR hole takes **"none"** when the ancestor holds no PR, and the
|
|
125
|
+
sentence reads "none — this thread created no pull request". A hole left
|
|
126
|
+
empty reads as an oversight, and a successor will ask about it. Step 1
|
|
127
|
+
becomes a no-op the successor states in its summary rather than a step it
|
|
128
|
+
invents work for.
|
|
129
|
+
|
|
130
|
+
## Invariants
|
|
131
|
+
|
|
132
|
+
- The brief ships verbatim: holes filled, nothing composed around it —
|
|
133
|
+
the successor's first prompt is the recipe, not prose.
|
|
134
|
+
- A watch lives on the session that made it: the successor re-watches every
|
|
135
|
+
carried PR from its own session, and your unwatch comes after its state
|
|
136
|
+
summary, in that order.
|
|
137
|
+
- The handback gate is the verified state summary — a successor that went
|
|
138
|
+
quiet is understanding unverified; hold the handback until the summary
|
|
139
|
+
holds.
|
|
140
|
+
- The ancestor settles its own thread only after that gate. An unsettled
|
|
141
|
+
ancestor is a thread that wakes on every send for ever.
|