Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

leyline

Infrastructure and pipeline building blocks for plugins.

Overview

Leyline provides reusable infrastructure patterns that other plugins build on. Think of it as a standard library for plugin development - error handling, authentication, storage, and testing patterns.

Installation

/plugin install leyline@claude-night-market

Skills

SkillDescriptionWhen to Use
service-registryService discovery, rate limiting and quotas, telemetryManaging external tool connections, consuming rate-limited APIs, logging tool usage
error-patternsStandardized error handling patternsProduction-grade error recovery
damage-controlRecovery protocols for broken agent stateCrash recovery, context overflow, merge conflicts
content-sanitizationSanitization for external contentLoading Issues, PRs, Discussions, or WebFetch results
markdown-formattingLine wrapping and style conventionsGenerating or editing markdown prose
authentication-patternsAuth flow patternsHandling API keys and OAuth
evaluation-frameworkDecision thresholds and utility-guided action selectionBuilding evaluation criteria or gating agent dispatch
progressive-loadingDynamic content loadingLazy loading strategies
risk-classificationInline 4-tier risk classification for agent tasksRisk-based task routing with war-room escalation
stewardshipCross-cutting stewardship principles with five virtues (Care, Curiosity, Humility, Diligence, Foresight)Working with project health, codebase improvement, or virtue-aligned development
testing-quality-standardsTest quality guidelines and pytest configurationEnsuring high-quality tests and standardized test configuration
decision-journalContracts for the decision journal, deferred-item capture, and storage templatesRecording a tradeoff or lesson, building a deferred-capture wrapper, or organizing stored knowledge
git-platformGit platform detection and cross-platform commandsAbstracting GitHub/GitLab/Bitbucket differences
ticket-writingGlanceable tickets with the why inline or one link awayCreating or editing Jira, GitLab, or GitHub tickets
supply-chain-advisoryKnown-bad version detection, lockfile auditing, incident responseAfter supply chain advisories, dependency audits, or suspected compromise
sem-integrationsem CLI detection, install-on-first-use, fallback patternsSkills consuming git diff output that benefit from entity-level diffs
additive-bias-defenseScrutiny questions challenging unnecessary additionsReviewing proposals that add new code, files, or abstractions
utilityExpected-gain scoring for candidate agent actionsGuiding action selection in agentic workflows

Commands

CommandDescription
/reinstall-all-pluginsUninstall and reinstall all plugins to refresh cache
/update-all-pluginsUpdate all installed plugins from marketplaces
/verify-pluginVerify plugin trust via ERC-8004 Reputation Registry

Usage Examples

Plugin Management

# Refresh all plugins (fixes version mismatches)
/reinstall-all-plugins

# Update to latest versions
/update-all-plugins

Using as Dependencies

Leyline skills are typically used as dependencies in other plugins:

# In your skill's SKILL.md frontmatter
dependencies:
  - leyline:error-patterns
  - leyline:service-registry  # quota-management module

Error Handling Pattern

Skill(leyline:error-patterns)

# Provides:
# - Structured error types
# - Recovery strategies
# - Logging standards
# - User-friendly messages

Authentication Pattern

Skill(leyline:authentication-patterns)

# Covers:
# - API key management
# - OAuth flows
# - Token refresh
# - Secret storage

Testing Standards

Skill(leyline:testing-quality-standards)

# Enforces:
# - Test naming conventions
# - Coverage requirements
# - Mocking guidelines
# - Fixture patterns

Modules

frontmatter

Canonical YAML frontmatter parser shared across plugins.

from leyline.frontmatter import parse_frontmatter

content = """---
name: my-skill
category: testing
---

# My Skill
"""
meta = parse_frontmatter(content)
# {'name': 'my-skill', 'category': 'testing'}

When PyYAML is installed, it uses yaml.safe_load. When unavailable, it falls back to a minimal key-value parser that handles simple key: value pairs (no nested structures). Returns None for content without frontmatter.

Other plugins should import this instead of reimplementing frontmatter parsing.

Pattern Categories

Rate Limiting

# service-registry quota-management module
from leyline.quota_tracker import QuotaTracker

tracker = QuotaTracker(service="my-service")
level, warnings = tracker.get_quota_status()
if level != "critical":
    # Make the API call, then record it
    tracker.record_request(tokens=500)

Telemetry

# service-registry usage-logging module
from leyline.usage_logger import UsageEvent, UsageLogger

logger = UsageLogger(service="my-service")
logger.log_usage(UsageEvent("WebFetch", tokens=500, duration=1.2))

Storage Abstraction

The decision-journal storage-templates module is guidance with no Python API: it gives directory layouts and file templates for a plugin to copy, not a class to import.

Discussion Operations (GitHub Only)

The git-platform skill’s command-mapping module provides GraphQL templates for GitHub Discussions. These templates are consumed by attune (war room publishing), imbue (scope-guard linking), memory-palace (knowledge promotion), and minister (playbook rituals).

Supported operations: create, comment, threaded reply, mark-as-answer, search, get-by-number, update, and list-by-category. Category resolution from slug to nodeId is included as a prerequisite step.

On non-GitHub platforms (GitLab, Bitbucket), all Discussion operations are skipped with a warning.

Two SessionStart hooks reach GitHub, and both are off until the user turns on a leyline plugin option. Claude Code shows the options when the plugin is enabled and lists them in /config.

  • discussions_context: fetch-recent-discussions.sh queries the 5 most recent “Decisions” discussions and injects a summary (<600 tokens) so that new sessions can discover prior deliberations.
  • star_repo: the async auto-star-repo.sh stars the repository once and tells the user. A marker stops every later run, it never unstars, and it fails silently if no auth method is available.

Integration

Leyline is used by:

  • abstract: Plugin validation uses error patterns
  • conjure: Delegation uses quota management
  • conservation: Context optimization uses MECW patterns

Best Practices

  1. Don’t Duplicate: Use leyline patterns instead of reimplementing
  2. Compose Patterns: Combine multiple patterns for complex needs
  3. Test with Standards: Use the testing-quality-standards pytest-config module for consistent testing
  4. Log Everything: Use service-registry usage logging for debugging and analytics
  • abstract: Uses leyline for plugin infrastructure
  • conjure: Uses leyline for quota and service management
  • conservation: Uses leyline for MECW implementation