mcpField
I
imperatives

imperatives

github.com/camachoAgent workflows296 installs
Repository

About imperatives

imperatives is an agent skill that extracts atomic requirements from Markdown instruction files into JSONL, then supplements keyword-based results with subagent review. It is intended for workflows that need structured, traceable policy statements.

Key features

  1. 01Keyword-based imperative extraction
  2. 02Subagent review for implicit rules
  3. 03JSONL output with structured fields
  4. 04Configurable file globs and output path
  5. 05Summary grouped by level and tool scope

Use cases

  1. 01Convert workspace rules into structured records
  2. 02Find obligations missed by keyword matching
  3. 03Prepare instruction data for policy-algebra or distill

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/camacho/ai-skills --skill imperatives

After installing, type/imperativesin Claude Code to confirm it loaded.

Bundled filesscripts/extract-imperatives.ts

Details

From the project README

/imperatives

Extract atomic imperatives (MUST/SHOULD/MAY) from markdown instruction files into JSONL.

Usage

/imperatives                                # default: ai-workspace/rules/*.md + AGENTS.md
/imperatives .claude/rules/*.md             # specific globs
/imperatives --output imperatives.jsonl     # write to file

Steps

  1. Resolve files. Default: ai-workspace/rules/*.md and AGENTS.md. Expand globs to absolute paths. Zero matches → error, stop.

  2. Pass 1 — Script extraction (fast, deterministic).

    node --import tsx "${SKILL_DIR}/scripts/extract-imperatives.ts" <files...> --output /tmp/imperatives-pass1.jsonl
    

    ${SKILL_DIR} = this skill's base directory (shown in the "Base directory for this skill:" header above). Keyword-based: catches RFC 2119 terms + imperative verbs. ~80% coverage, <1s.

  3. Pass 2 — Subagent reasoning (catches implicit imperatives). For each file, dispatch a subagent to identify imperatives the regex missed — contextual rules, implicit constraints, prose-embedded obligations.

    Subagent prompt:

    Read <file>. Here are the imperatives already extracted by the script for this file:

    <pass 1 JSONL lines where source.file matches>
    

    Identify additional imperative statements the regex missed. Look for:

    • Implicit obligations hidden in prose (e.g., "The workflow is a menu, not a pipeline" implies MUST NOT enforce order)
    • Contextual constraints (e.g., section context that makes a statement imperative)
    • Conditional rules not triggered by keyword patterns

    For each new imperative found, output one JSON line (same schema — id, level, polarity, subject, predicate, when, source, tool_scope, tags, raw). Do NOT duplicate entries already in pass 1. If none found, output nothing.

    Use subagent_type: "explorer" (Haiku) for most files. If a file had zero pass-1 imperatives OR contains dense prose (>50 lines without a keyword match), escalate that file to Sonnet for deeper reasoning.

  4. Merge passes. Concatenate pass 1 + pass 2 outputs. Deduplicate by raw text. Write final output to --output <path> or present inline.

  5. Present summary. Report in a table:

    • Total count (pass 1 baseline + pass 2 additions)
    • Breakdown by level and tool_scope
    • Files with zero imperatives after both passes
    • Pass 2 additions highlighted separately
  6. Downstream callers. If invoked by /policy-algebra or /distill, return the JSONL path directly — skip the summary.

Failure modes

ConditionBehavior
No files matchedError message. Stop.
File not foundScript warns on stderr, continues with remaining files.
Zero imperativesReport zero. Not an error.
Script exits non-zeroSurface stderr to user.

Cross-tool notes

  • Codex / Cursor: run the script directly — it's tool-agnostic.

Comments

Markdown supported