Cp skill connect

From zby/commonplace · View interactive version

Cp skill connect is an AI agent skill from the GitHub repository zby/commonplace. Discover connections for a single artifact. Writes a connect-report under kb/workflow-state/data/current/connect/<collection>/ without mutating library artifacts or indexes. Use with an artifact path or artifact name.

How to use this skill

Skill file

Connect — Discovery Only

Find candidate connections for a single artifact and write them to a discovery report at kb/workflow-state/data/current/connect/<collection>/<artifact-name>.connect.md. The report is the only direct write this skill performs. Do not edit the source artifact, other artifacts, indexes, collection files, or logs.

Connect reports are gitignored; they are immediate downstream context and can be regenerated from the source artifact plus current KB state.

The skill owns execution. The type owns the report contract.

Use this skill for routing, setup, tool use, delegated skill calls, and file writes.

Use the loaded type spec for section meanings, quality standards, and the template.

If the skill and type both mention the same report-content rule, prefer the type.

Input

Target: $ARGUMENTS — one artifact path or artifact name. If none provided, ask which artifact to connect. Determine the source collection from the artifact's path (kb/theory/ -> theory, kb/reference/ -> reference, etc.).

Setup

  1. Determine the source collection from the target artifact's path (kb/theory/... -> theory, kb/reports/retained/foo.md -> reports, etc.). Hard fail immediately if kb/<source-collection>/COLLECTION.md does not exist — do not attempt discovery, do not fall back to defaults, do not soldier on. Report the missing file path to the user and stop. The COLLECTION.md is the only linking-rules surface; without it the skill has no authorised destinations or labels and any output would be invented.
  2. Read the global CODE0 type spec before candidate discovery. It defines the report sections, quality standards, and template you will use while judging candidates.
  3. Read the target artifact fully. Identify its claim, mechanism, implications, scope, and tensions. If the target has no frontmatter (text file), continue discovery from its title/body and mark the report as provisional.
  4. Read kb/<source-collection>/COLLECTION.md and find its outbound-linking section (heading varies — look for the one that names destinations and labels). Read it as authoritative guidance — extract three things, regardless of whether the section is structured as per-destination blocks, a single labels table with a destinations column, prose, or any mix:

This is the only linking-rules surface. There is no compiled topology and no separate vocabulary doc to consult.

  1. Use the project’s AGENTS.md goals to decide whether a candidate is in scope; the collection contract decides whether its label is authorised. In a forked invocation, rely on inherited goals only if the runtime supplied them. Otherwise read the project’s goals before applying the scope check.
  2. Use repo-local discovery only: curated indexes, scoped rg, and link following. Do not call external semantic-search tools or MCP search services; connect must work in Codex without external search state. Complete generated listings (dir-index.md, tag tails) are build-time site artifacts and do not exist in the repo (ADR 025).

Discovery — per destination

Connect is the skill that pays the cost of active search. The write skill is bounded to a targeted duplicate check + already-loaded context + user-named targets; connect runs the full prospecting procedure on every local destination collection the source's COLLECTION.md permits.

Active depth: standard (quick: index-only single pass; deep: full discovery, multiple passes, synthesis detection).

Capture discovery trace throughout — indexes read, actual query strings, candidate evaluations, and links followed. A trace with only keywords is insufficient.

When a candidate first appears, note which discovery surface exposed it, and note any later surface that exposes it again. The report's Candidate origins subsection records these per kept candidate; origins reconstructed after discovery are unreliable.

For each local destination collection authorised by the source's outbound section:

1. Decide breadth from the source COLLECTION.md's guidance

Use the outbound section's triggers, latitude cues, and direction hints to set prospecting breadth. If the source has no plausible match for a destination's trigger, note that in the trace and skip that destination.

The reserved external destination is authorization for already-known targets, not a prospecting surface. Do not search or browse the open web for candidates. If an external target was supplied by the user or is already present in loaded context, it may be evaluated under the collection's external rules; otherwise record that external prospecting is skipped.

2. Prospect using repo-local tools

In order of cost:

```bash

rg -N --no-filename -m1 '^# (.)' -r '$1' kb/<destination>/ --glob '.md' --glob '!*.brief.md'

```

The listing omits paths: a filename repeats its title, so paths double the listing. Resolve a path only for a title worth pursuing:

```bash

rg -l -F -x '# <title>' kb/<destination>/

```

```bash

# whole destination

rg '^description:' kb/<destination>/ --glob '*.md'

# by tag: replace TAG with the literal kebab-case tag name

rg -l0 '^tags:\s\[\s([^]],\s)?TAG\s(,|\])' kb/<destination>/ --glob '.md' \

| xargs -0 -r rg -N --with-filename --no-heading '^description:\s*' -r ''

```

This matches whole names in the usual inline list, not every valid YAML spelling. Use it to find candidates, not to prove membership or absence. For tracked ingests use kb/sources/ --glob '*.ingest.md'; keep descriptions and body search available for untagged material. The xargs -r guard prevents an empty candidate list from starting another search.

```bash

rg -n "term" kb/<destination>/ --glob "*.md"

```

3. Articulation test

Every candidate must complete: [source] connects to [target] because [specific reason]. Keep the candidate only if an agent, or another intended KB consumer named by the collection contract, gains something concrete by following the link. The KB goal frame filters whether a plausible candidate is worth surfacing at all; candidate acceptance still depends on the articulation test and authorised labels.

4. Label the candidate from the destination's authorised set

Each authorised label carries a reader-need; pick the one whose reader-need matches the candidate connection's purpose, and record both label and a one-line context phrase in the report. The labels the source's outbound section authorises for this specific destination are the only options — do not propose labels outside that set. (Labels often appear in a single table with a destinations column; filter to rows whose destinations include the current target collection.)

If a candidate passes the articulation test but no authorised label fits, it is either off-scope or a signal that the collection author should extend the authorisation. Move it to Off-authorisation Candidates in the report. Do not invent a label or downgrade to see-also to make it fit.

The label and context phrase are recorded in the report — connect does not write them anywhere else.

Honour collection-specific posture

Some COLLECTION.md files declare global postures that constrain prospecting beyond the per-label rules. Examples to respect when present:

Read these from the outbound section before prospecting, not after.

Reverse-edge candidates

Not every useful link is authored from the source side. When the useful direction is inbound, prospect for artifacts elsewhere that should link to this target under their own COLLECTION.md rules. Surface those as Reverse-edge Candidates; do not edit the other artifacts.

The source COLLECTION.md often flags this directly — language like "the usual direction is inverse" or "primary edge is authored from another collection" tells you to look for reverse edges from the named direction. When such a hint is present, treat reverse-edge prospecting as a first-class pass for that destination, not an afterthought.

The skill does not edit those source artifacts or write draft links from them. It names the candidate reverse edges so the author of the source artifact (or a future connect run on the source) can decide whether to author the link.

Authored surfaces

Snapshots in kb/sources/ are immutable; their authored connection surface is normally the matching .ingest.md. For other non-authored artifacts, use the authored companion named by the collection contract, if one exists. If none exists, keep the suggestion in the connect report.

Output

Save the report to kb/workflow-state/data/current/connect/<source-collection>/<artifact-name>.connect.md. <artifact-name> is the target's filename without its final .md and nothing else: foo.md gives foo.connect.md, and foo.ingest.md gives foo.ingest.connect.md. Dropping an inner suffix would overwrite another artifact's report. Use the loaded connect-report template (type: types/connect-report.md) and file-relative markdown links in the body. Tell the user: Report saved: <full path>.

Every section describes candidate signal for a future writer to act on. The connect skill does not author any of these edges into any artifact — the report is the entire connection deliverable.

Constraints

Never edit the target artifact, other artifacts, indexes, collection files, logs, or any library artifact — the report is the only connection output the skill produces. Every section is a candidate signal for future authoring, not committed state.

Never add "related" connections without specific reasoning. Never force connections — if no genuine connections exist, say so honestly. Never propose a label outside the destination's authorised set; route those to Off-authorisation Candidates.

Always capture discovery trace per destination. Always validate the saved report. Always read the source COLLECTION.md's outbound-linking section before prospecting — it is the only authoritative linking-rules surface, regardless of how that section is internally structured.

Maintenance observations

Use Maintenance Observations for report-local traversal observations that are not connection candidates. This is a best-effort signal inside a gitignored, regenerable report. A later explicit maintenance or triage step may promote entries from this section into durable local artifacts; connect does not do that promotion.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.