Extract Context Directive Records (CDRs) from the current session after completing work. Identifies reusable patterns (rules, personas, examples, evals) and captures directive compliance cases for team-ai-directives.
npx skills add https://github.com/tikalk/adlc-team-skills --skill levelup-specify
Extract Context Directive Records (CDRs) from the current session after completing work.
This is the primary command for capturing learnings from completed work:
{REPO_ROOT}/.adlc/drafts/cdr/CDR-{NNN}.md with status Proposed{REPO_ROOT}/.adlc/drafts/cdr/cdr.md indexKey Difference from /levelup-init:
/levelup-init = Discovers patterns from existing codebase (brownfield)/levelup-specify (this skill) = Extracts patterns from the current session (greenfield)This skill focuses on session-level learnings — what reusable knowledge emerged from the work just completed.
/levelup-init to scan existing code/team-repair for health checks$ARGUMENTS
You MUST consider the user input before proceeding (if not empty).
Examples of User Input:
"Focus on error handling patterns" — Extract CDRs related to error handling"Document the testing approach" — Focus on testing patterns"CDR-001" — Enrich an existing CDR with more session evidence"--focus skills" — Only propose skill-type CDRs--focus AREA: Focus on specific context typerules: Only propose rule CDRspersonas: Only propose persona CDRsexamples: Only propose example CDRsconstitution: Only propose constitution amendment CDRsskills: Only propose skill CDRs--cdr-id ID: Enrich an existing CDR with session evidence instead of creating new onesYou are acting as a Context Extractor — identifying reusable patterns from the current session. Your role involves:
| Scenario | Command | Input | Output |
|---|---|---|---|
| Brownfield (existing code) | /levelup-init | Codebase scan | Discovered CDRs |
| Greenfield (session complete) | /levelup-specify | Current session | Proposed CDRs |
cdr.mdRun the setup script from the skill's base directory:
scripts/bash/setup-levelup-specify.sh
Parse JSON output for paths and next CDR number.
If the setup script is unavailable or fails, resolve paths manually:
REPO_ROOT — walk up from cwd to find a directory containing .adlc/, or use git rev-parse --show-toplevel, or use pwd.TEAM_AI_DIRECTIVES — check TEAM_AI_DIRECTIVES env var, then REPO_ROOT/.adlc/init-options.json → team_ai_directives field, then fallback to REPO_ROOT/team-ai-directives.CDR_DRAFTS_DIR — REPO_ROOT/.adlc/drafts/cdrNEXT_CDR — list CDR_DRAFTS_DIR/CDR-*.md, find the highest number, increment by 1, zero-pad to 3 digits (e.g., 001).If TEAM_AI_DIRECTIVES is not configured:
Team AI directives repository not configured.
Run: team-setup
Or set: export TEAM_AI_DIRECTIVES=/path/to/team-ai-directives
Review the current session to identify what happened. The agent directly observes the session — no trace file is needed.
git diff --stat, git log --oneline -10)Also collect implementation evidence:
# Files changed
git diff --stat 2>/dev/null
# Recent commits
git log --oneline -10 2>/dev/null
# New/untracked files
git status --short 2>/dev/null
Read {REPO_ROOT}/.adlc/drafts/cdr/CDR-*.md:
--cdr-id: load that specific CDR for enrichmentFor each context type, look for reusable patterns from the session and evidence:
Rules: Coding conventions, error handling, testing patterns, security practices
Personas: Roles that emerged during implementation (e.g., "API consumer", "DevOps operator")
Examples: Code patterns worth reusing
Skills: Capabilities that could be packaged as agent skills (especially reusable workflows)
Constitution Amendments: Cross-cutting principles discovered during the session
Skill-Type CDRs: Yes, /levelup-specify can propose skill-type CDRs. The actual SKILL.md is built later by /levelup-publish --skill <name>.
Eval CDRs: For each directive CDR extracted (rule, persona, example, constitution), also extract a paired eval CDR with binary pass/fail cases from the session:
Each case is self-contained — it includes the scenario, input context, agent output, and why it passes/fails. The case does not depend on an external trace file; the evidence is inline.
Eval CDRs use ### Context Type: Eval and reference their paired directive CDR via ### Paired Directive CDR: CDR-NNN.
For each extracted pattern, create or enrich a CDR:
## CDR-NNN: [Title]
### Status: **Proposed**
### Date: [YYYY-MM-DD]
### Source: Session evidence via /levelup-specify
### Target Module: `context_modules/rules/[domain]/[file].md` or `skills/[skill-name]/`
### Context Type: Rule | Persona | Example | Skill | Constitution Amendment
### Descriptor: One-line "when to use" summary.
### Context
[What reusable pattern was identified]
### Evidence
**Session**: [brief session description]
**Branch**: [branch-name]
**Implementation Evidence**:
- [file/path]: [description]
- `{commit-sha}`: [commit message]
### Decision
[What should be contributed to team-ai-directives]
Eval CDR format (paired with a directive CDR):
## CDR-NNN: [Eval Title]
### Status: **Proposed**
### Date: [YYYY-MM-DD]
### Source: Session evidence via /levelup-specify
### Target Module: `evals/{directive-id}/goldset.md`
### Context Type: Eval
### Paired Directive CDR: CDR-NNN
### Descriptor: One-line "what directive this eval tests"
### Context
[What behavior is being tested and why]
### Pass Cases
1. **Source**: session "[brief description]"
**Scenario**: [what was asked]
**Input context**: [what context was loaded]
**Agent output**: [what the agent did]
**Why it passes**: [why this follows the directive]
### Fail Cases
1. **Source**: session "[brief description]"
**Scenario**: [what was asked]
**Input context**: [what context was loaded]
**Agent output**: [what the agent did — the violation]
**Why it fails**: [why this violates the directive]
**Correction**: [what should have been done]
### Adversarial Cases
1. **Scenario**: [edge case]
**Expected**: [correct behavior]
### Evidence
**Session**: [brief session description]
**Paired Directive**: CDR-NNN
When enriching an existing CDR, append to the ### Evidence section and update the enrichment timestamp.
Regenerate {REPO_ROOT}/.adlc/drafts/cdr/cdr.md by listing all CDR-*.md files and building a markdown table. For each CDR, extract these single-line fields:
ID — from filename (e.g., CDR-001)Target Module — from ### Target Module: lineType — from ### Context Type: lineStatus — from ### Status: lineCreated — from ### Date: lineDescriptor — from ### Descriptor: lineFormat:
# Context Directive Records (Drafts)
## CDR Index
| ID | Target Module | Type | Status | Created | Verified | Age | Descriptor |
|----|---------------|------|--------|---------|----------|-----|------------|
| CDR-001 | context_modules/rules/... | Rule | Proposed | 2026-07-21 | - | - | One-line summary |
**Stats**: N entries | Last Updated: YYYY-MM-DD
## LevelUp Specify Summary
**Session**: [brief description]
**Date**: [date]
**CDRs Created**: N
**CDRs Enriched**: N
### CDRs by Type
| Type | Count |
|---|---|
| Rules | N |
| Examples | N |
| Skills | N |
| Personas | N |
| Constitution Amendments | N |
| Evals | N |
### Handover
**Next**: Run `/levelup-clarify` to review the N proposed CDRs.
CDRs are in `Proposed` status and cannot be published until accepted.
Handoff context:
{
"source": "session",
"command": "specify",
"cdrs_created": ["CDR-001", "CDR-002"],
"cdrs_enriched": [],
"next": "clarify"
}
/levelup-clarify to review proposed CDRs/levelup-publish for accepted CDRs
### Key Rules
#### Link Evidence, Don't Fabricate
- Every CDR must link to concrete session evidence
- Cite specific file paths, commit SHAs, or test cases
- Do not invent evidence
#### Avoid Duplicates
- Check existing CDRs before creating new ones
- If a similar pattern exists, enrich it instead of duplicating
#### Skill CDRs Are Records, Not Skills
- `/levelup-specify` creates CDRs with `Context Type: Skill`
- It does **not** create `SKILL.md` files directly
- Skill artifacts are built by `/levelup-publish --skill <name>`
#### Signal Gate Applies Later
- Create CDRs generously from session evidence
- The signal gate (team-wide, high-value, unique, evidence) is applied at `/levelup-publish`
### Workflow Guidance & Transitions
#### After `/levelup-specify`
**Required**: Run `/levelup-clarify` to review proposed CDRs.
#### Complete CDR Lifecycle
[Agent session — work completed]
↓
/levelup-specify
↓
[Extract patterns + paired evals] → Write CDRs to .adlc/drafts/cdr/CDR-{NNN}.md (Proposed)
↓
[Run /levelup-clarify] → Review and accept/reject CDRs (evals gate runs existing goldensets)
↓
[Run /levelup-publish] → Compile accepted CDRs into team-ai-directives PR
↓
[Run /team-repair] → Re-index and validate team AI directives after merge
## Next Steps
After `/levelup-specify` completes, run `/levelup-clarify` to review the proposed CDRs.
## Verification
- CDRs written to `{REPO_ROOT}/.adlc/drafts/cdr/CDR-{NNN}.md` with status **Proposed**.
- Auto-generated `cdr.md` index exists in `{REPO_ROOT}/.adlc/drafts/cdr/`.
- Each CDR includes session implementation evidence.
- Eval CDRs are paired with their directive CDRs and contain self-contained pass/fail cases.
- Existing CDRs were enriched rather than duplicated when applicable.
## Configuration
- `TEAM_AI_DIRECTIVES` — Path to the team AI directives (overrides `.adlc/init-options.json`).
- `.adlc/init-options.json` — Project-level config file with `team_ai_directives` field.
- Default fallback: `team-ai-directives/` relative to project root.
## 12-Factor Alignment
Factor IX (Traceability) — extracts reusable patterns from session evidence for team-wide contribution.
## Context
$ARGUMENTS
Take tikalk/levelup-specify from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.