Progressive loading

From athola/claude-night-market · View interactive version

Progressive loading is an AI agent skill from the GitHub repository athola/claude-night-market. Implements hub-and-spoke lazy loading to minimize token usage in large skills. Use when building multi-module skills that need conditional on-demand loading.

How to use this skill

Skill file

Progressive Loading Patterns

Overview

Progressive loading provides standardized patterns for building skills that load modules dynamically based on context, user intent, and available token budget. This prevents loading unnecessary content while ensuring required functionality is available when needed.

The core principle: Start minimal, expand intelligently, monitor continuously.

When To Use

Use progressive loading when building skills that:

When NOT To Use

Quick Start

Basic Hub Pattern

## Progressive Loading

**Context A**: Load `modules/loading-patterns.md` for scenario A
**Context B**: Load `modules/selection-strategies.md` for scenario B

**Always Available**: Core utilities, exit criteria, integration points

Verification: Run the command with --help flag to verify availability.

Context-Based Selection

Modules are declared in the skill's YAML frontmatter and

loaded on demand with a @modules/ directive. The hub reads

the detected context, then loads only the spokes that match:

---
modules:
- modules/git-catchup-patterns.md
- modules/python-testing.md
---

When the intent is a branch or PR catch-up, load
`@modules/git-catchup-patterns.md`. When the artifacts include
Python tests, also load `@modules/python-testing.md`.

To keep loads within the MECW token budget, check whether a

module fits before pulling it in. The MECWMonitor in

plugins/leyline/src/leyline/mecw.py exposes the methods used

here:

from leyline.mecw import MECWMonitor

monitor = MECWMonitor()
monitor.track_usage(current_context_tokens)

# module_estimated_tokens comes from the module frontmatter
can_load, reasons = monitor.can_handle_additional(module_estimated_tokens)

Load the next module only when can_load is true. Each

module records its cost in its frontmatter estimated_tokens

field.

Hub-and-Spoke Architecture

Hub Responsibilities

  1. Context Detection: Identify user intent, artifacts, workflow type
  2. Module Selection: Choose which modules to load based on context
  3. Budget Management: Verify MECW compliance before loading
  4. Integration Coordination: Provide integration points with other skills
  5. Exit Criteria: Define completion criteria across all paths

Spoke Characteristics

  1. Single Responsibility: Each module serves one workflow or domain
  2. Self-Contained: Modules don't depend on other modules
  3. Context-Tagged: Clear indicators of when module applies
  4. Token-Budgeted: Known token cost for selection decisions
  5. Independently Testable: Can be evaluated in isolation

Selection Strategies

See modules/selection-strategies.md for detailed strategies:

Loading Patterns

See modules/loading-patterns.md for implementation patterns:

Common Use Cases

Best Practices

  1. Design Hub First: Define all possible contexts and module boundaries
  2. Tag Modules Clearly: Use YAML frontmatter to indicate context triggers
  3. Measure Token Cost: Know the cost of each module for selection
  4. Monitor Loading: Track which modules are actually used
  5. Validate Paths: Verify all context paths have required modules
  6. Document Triggers: Make context detection logic transparent

Module References

Core (always available to the hub)

Context-Specific Pattern Modules

These modules are loaded on demand by the hub based on

detected artifacts and user intent. They are listed in

frontmatter so the selector can match them, but the hub

should only load the ones whose activation context fires.

Operating-system patterns (load on detected platform):

Language and runtime patterns (load on detected ecosystem):

Workflow patterns (load on detected task):

Reference material (load only when explicitly cited):

last; tokens are non-trivial)

Integration with Other Skills

This skill provides foundational patterns referenced by:

Reference in your skill's frontmatter:

dependencies: [leyline:progressive-loading, conserve:context-optimization]
progressive_loading: true

Verification: Run the command with --help flag to verify availability.

Exit Criteria

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.