CtrlK
BlogDocsLog inGet started
Tessl Logo

spec-driven-development/spec-as-source

Spec-driven development on OpenSpec, with mechanical spec-as-source enforcement: a custom 'spec-as-source' OpenSpec schema adds file-ownership (targets) and test-verification ([@test]) metadata to every capability spec, three scripts (link check, ownership check, manifest build) keep code and specs from drifting apart, plus requirement-gathering, spec-writer, work-review, and a session-handoff skill with a proactive context-warning hook.

68

Quality

85%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

install.shskills/skill-router/

#!/usr/bin/env bash
# GENERATED FROM SPEC — DO NOT EDIT DIRECTLY
# Source: openspec/specs/skill-router/spec.md
#
# Register skill-router as the single global entry point, by symlink.
#
# A copy would create a second source of truth that diverges in silence — this
# machine already carries the proof: ~/.claude/skills/handoff and spec-writer
# drifted from the repo by 64 and 253 lines with no error ever raised. A symlink
# keeps one.
set -euo pipefail

SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILLS_HOME="${HOME}/.claude/skills"
LINK="${SKILLS_HOME}/skill-router"

check_only=0
[ "${1:-}" = "--check" ] && check_only=1
if [ -n "${1:-}" ] && [ "${1:-}" != "--check" ]; then
    echo "usage: install.sh [--check]" >&2
    exit 2
fi

say() { printf '%s\n' "$*"; }

# --- Report obsolete same-named skills, never remove them -------------------
#
# Removing files from the operator's ~/.claude/skills is not this script's call
# to make: it is plan entry E04, a deliberate decision. Reporting is in scope.
report_shadows() {
    local found=0
    [ -d "$SKILLS_HOME" ] || return 0
    local skills_root
    skills_root="$(cd "$SKILL_DIR/.." && pwd -P)"
    for repo_skill in "$skills_root"/*/; do
        local name shadow canonical
        name="$(basename "$repo_skill")"
        [ "$name" = "skill-router" ] && continue
        shadow="$SKILLS_HOME/$name/SKILL.md"
        canonical="${repo_skill}SKILL.md"
        [ -f "$shadow" ] || continue
        [ -f "$canonical" ] || continue
        if ! cmp -s "$shadow" "$canonical"; then
            [ "$found" -eq 0 ] && say "" && say "Obsolete same-named skills registered globally:"
            found=1
            say "  $name — $(wc -l < "$shadow" | tr -d ' ') lines globally vs $(wc -l < "$canonical" | tr -d ' ') in the repo"
            say "      global: $shadow"
        fi
    done
    if [ "$found" -eq 1 ]; then
        say ""
        say "  These still auto-trigger: the router governs what happens when it is"
        say "  invoked, not what the harness loads. Removing them is a separate,"
        say "  deliberate act (plan entry E04) — this script does not touch them."
    fi
}

# --- Read-only mode ---------------------------------------------------------
if [ "$check_only" -eq 1 ]; then
    if [ -L "$LINK" ]; then
        resolved="$(cd "$LINK" 2>/dev/null && pwd -P || true)"
        if [ "$resolved" = "$(cd "$SKILL_DIR" && pwd -P)" ]; then
            say "install: INSTALLED — $LINK -> $resolved"
        else
            say "install: WRONG TARGET — $LINK -> ${resolved:-<broken>}"
            say "         expected $SKILL_DIR"
        fi
    elif [ -e "$LINK" ]; then
        say "install: BLOCKED — $LINK exists and is not a symlink"
    else
        say "install: NOT INSTALLED — $LINK does not exist"
    fi
    report_shadows
    exit 0
fi

# --- Refuse to clobber a real directory -------------------------------------
if [ -e "$LINK" ] && [ ! -L "$LINK" ]; then
    say "install: FAILED — $LINK already exists and is not a symlink." >&2
    say "         Nothing was deleted. Move or remove it yourself, then re-run." >&2
    exit 1
fi

# --- Idempotent ------------------------------------------------------------
if [ -L "$LINK" ]; then
    current="$(cd "$LINK" 2>/dev/null && pwd -P || true)"
    if [ "$current" = "$(cd "$SKILL_DIR" && pwd -P)" ]; then
        say "install: already installed — $LINK -> $current"
        report_shadows
        exit 0
    fi
    say "install: replacing a symlink that pointed elsewhere ($current)"
    rm "$LINK"
fi

mkdir -p "$SKILLS_HOME"
ln -s "$SKILL_DIR" "$LINK"

# --- Verify AFTER linking ---------------------------------------------------
#
# A broken symlink looks perfect in `ls` and only fails at use. Resolve it and
# read through it.
if [ ! -r "$LINK/SKILL.md" ]; then
    say "install: FAILED — $LINK does not resolve to a readable SKILL.md" >&2
    exit 1
fi
say "install: linked $LINK -> $(cd "$LINK" && pwd -P)"
say "install: resolves to a readable SKILL.md"
say ""
say "Restart your agent session: skills are loaded at startup."
report_shadows

skills

README.md

tile.json