Compile accepted Context Directive Records (CDRs) into team-ai-directives artifacts and create a draft PR. Builds context modules, evals goldensets, and/or skills based on CDR context types.
npx skills add https://github.com/tikalk/adlc-team-skills --skill levelup-publish
Compile accepted CDRs into actual artifacts in the team-ai-directives team AI directives and create a draft PR.
It is the implementation phase of the CDR lifecycle:
goldset.md + goldset.json) for eval-type CDRsSKILL.md + .skills-entry.json).skills.json manifestCDR.md index in team-ai-directivesThis skill does not run until CDRs have been accepted via /levelup-clarify.
/levelup-clarify: Accepted CDRs need to be published--skill <name|CDR-id> to build one skill--context-only to skip skill generation/levelup-clarify first/levelup-init or /levelup-specify/levelup-clarify$ARGUMENTS
You MUST consider the user input before proceeding (if not empty).
Examples of User Input:
"--ready" — Create ready PR instead of draft"--skip-skills" — Don't include skill CDRs"--context-only" — Only build context modules"--skill CDR-005" — Build only the skill from CDR-005"CDR-001 CDR-003" — Only implement specific CDRs--ready: Create ready PR instead of draft--skip-skills: Skip skill-type CDRs--context-only: Build only context modules (skip all skills)--skill <name|CDR-id>: Build only one skill from a specific accepted skill CDRYou are acting as a Context Publisher — moving accepted CDRs from local drafts to team-ai-directives.
Your role involves:
10. AGENTS.md Check (Phase 9): Create if missing
11. Commit and PR (Phase 10): Publish changes
12. Summary (Phase 11): Report results
Run:
scripts/bash/setup-levelup-publish.sh
Parse JSON for REPO_ROOT, TEAM_AI_DIRECTIVES, CDR_DRAFTS_DIR, ACCEPTED_CDRS, TD_CONFIGURED, TD_IS_GIT, TD_CLEAN.
If the setup script is unavailable or fails, resolve manually:
REPO_ROOT — walk up from cwd to find .adlc/, or git rev-parse --show-toplevel, or use pwd.TEAM_AI_DIRECTIVES — TEAM_AI_DIRECTIVES env var, then .adlc/init-options.json → team_ai_directives, then REPO_ROOT/team-ai-directives.CDR_DRAFTS_DIR — REPO_ROOT/.adlc/drafts/cdrACCEPTED_CDRS — grep -l '^### Status: \*\*Accepted\*\*' CDR_DRAFTS_DIR/CDR-*.md and extract IDs.TD_IS_GIT — git -C "$TEAM_AI_DIRECTIVES" rev-parse --is-inside-work-tree (exit 0 = true).TD_CLEAN — git -C "$TEAM_AI_DIRECTIVES" status --porcelain (empty = clean).If TD_IS_GIT is false, Phase 10 (branch/commit/PR) cannot run. Offer to git init the team AI directives or write files directly without git.
Verify Team Directives configured:
Team AI directives repository not configured.
Run: team-setup
Or set: export TEAM_AI_DIRECTIVES=/path/to/team-ai-directives
Check Working Tree:
If TD_CLEAN is false:
team-ai-directives has uncommitted changes.
Please commit or stash changes before running /levelup-publish.
Check Accepted CDRs:
If ACCEPTED_CDRS is empty:
No accepted CDRs found.
Run /levelup-clarify to accept CDRs first.
For each accepted CDR, evaluate it against these four criteria:
context_modules/rules/, context_modules/examples/, and CDR.md for overlapping content. If it overlaps → SKIP (reason: "duplicate").Skip CDRs that fail any criterion. Skipped CDRs remain in local drafts.
Report:
## Signal Gate Validation
**Passing**: N | **Skipped**: M
### Skipped CDRs
| CDR | Reason |
|---|---|
| CDR-003 | No evidence |
| CDR-005 | Project-specific |
Check for:
If conflicts found:
Cross-CDR conflicts detected. Resolve via /levelup-clarify before implementing.
Create branch in team-ai-directives (skip if TD_IS_GIT=false — git operations are handled in Phase 10):
cd "$TEAM_AI_DIRECTIVES"
git checkout -b "levelup/$(basename "$REPO_ROOT")" main 2>/dev/null || git checkout -b "levelup/$(basename "$REPO_ROOT")"
For each accepted non-skill CDR, create/update the target file.
Extracting fields from CDRs: CDRs use single-line field format (### Field: value). Extract values by parsing the line after the ### prefix:
title — from the ## CDR-NNN: headingdescription — from ### Descriptor: lineid — from ## CDR-NNN heading (e.g., CDR-001)cdr_ref — same as iddomain — from ### Domain: line (default: general)context-type — from ### Context Type: line (lowercased; default: rule)created / modified / verified — from ### Date: line (use today's date for modified/verified if not present)evidence — from ### Feature Implementation Evidence or ### Evidence section body{Content from CDR} — from ### Context section bodyresource, tags, timestamp) are derived: resource = relative path from context type/domain/file, tags = context type, timestamp = ISO 8601 datetimeRules:
---
type: Rule
title: {title}
description: {description}
resource: ./context_modules/rules/{domain}/{file}.md
tags: [{context-type}]
timestamp: {today}T00:00:00Z
id: {id}
cdr_ref: {cdr_ref}
created: {created}
modified: {modified}
verified: {verified}
age_days: 0
evidence:
{evidence}
---
> ⚠️ **Memory Verification**
> This directive is 0 days old. Before applying:
> - [ ] Pattern still exists in current codebase
> - [ ] Rule is actively followed by team
> - [ ] No conflicting rules introduced
# {Title}
{Content from CDR}
## Source
Contributed from: {project-name}
CDR: {cdr_ref}
Personas and Examples follow similar templates with appropriate type.
Constitution:
context_modules/constitution.mdFor each accepted eval-type CDR, generate goldenset files in team-ai-directives/evals/.
Extracting fields from eval CDRs: Parse the CDR's single-line fields:
directive_id — from ### Paired Directive CDR: line (e.g., CDR-001)descriptor — from ### Descriptor: linepass_cases — from ### Pass Cases section bodyfail_cases — from ### Fail Cases section bodyadversarial_cases — from ### Adversarial Cases section bodyStep 1: Create evals directory
mkdir -p "$TEAM_AI_DIRECTIVES/evals/{directive_id}"
Step 2: Write goldset.md
Write {TEAM_AI_DIRECTIVES}/evals/{directive_id}/goldset.md:
---
type: Eval
title: {title from CDR}
description: {descriptor from CDR}
resource: ./evals/{directive_id}/goldset.md
tags: [eval]
timestamp: {today}T00:00:00Z
id: {eval CDR id}
cdr_ref: {eval CDR id}
paired_directive: {directive_id}
created: {date from CDR}
modified: {today}
verified: {today}
age_days: 0
---
# Goldset: {Title}
## Directive Under Test
- **CDR**: {directive_id}
- **Path**: {target module of paired directive CDR}
## Pass Cases
{pass cases from CDR — each with scenario, input, output, why-it-passes}
## Fail Cases
{fail cases from CDR — each with scenario, input, output, why-it-fails, correction}
## Adversarial Cases
{adversarial cases from CDR — each with scenario, expected}
Step 3: Write goldset.json
Write {TEAM_AI_DIRECTIVES}/evals/{directive_id}/goldset.json — machine-readable version for grader consumption:
{
"id": "{eval CDR id}",
"paired_directive": "{directive_id}",
"title": "{title}",
"description": "{descriptor}",
"cases": [
{
"id": "PASS-001",
"type": "pass",
"scenario": "...",
"input_context": "...",
"expected_output": "...",
"actual_output": "...",
"reason": "..."
},
{
"id": "FAIL-001",
"type": "fail",
"scenario": "...",
"input_context": "...",
"expected_output": "...",
"actual_output": "...",
"reason": "...",
"correction": "..."
}
]
}
Step 4: Report
Eval goldenset published: evals/{directive_id}/goldset.md
Eval goldenset JSON: evals/{directive_id}/goldset.json
Skip if --skip-skills or if all skill CDRs excluded.
For skill-type CDRs (or when --skill <name|CDR-id> is specified):
skills/{name}/SKILL.md:---
name: {name}
description: {description from CDR}
disable-model-invocation: true
---
# {name}
## What this skill does
{Summary}
## When to use
- {Trigger 1}
- {Trigger 2}
## Steps
1. {Step 1}
2. {Step 2}
## Example
{Minimal example}
## Verification
{How to verify}
## Related
- CDRs: {cdr_ref}
skills/{name}/.skills-entry.json:{
"name": "{name}",
"description": "{description}",
"version": "1.0.0",
"cdr_ref": "{cdr_ref}"
}
.skills.json:{
"local:./skills/{name}": {
"version": "1.0.0",
"description": "{description}",
"categories": ["..."]
}
}
AGENTS.md Skills section with the new skill.Create/update {TEAM_AI_DIRECTIVES}/CDR.md with accepted CDRs:
# Context Directive Records
## CDR Index
| ID | Target Module | Type | Status | Created | Verified | Age | Descriptor |
|---|---|---|---|---|---|---|---|
| CDR-001 | context_modules/rules/... | Rule | Accepted | ... | ... | 0 | ... |
If AGENTS.md is missing, create it from a template.
Verify files created, then follow the git decision tree:
Case A: team-ai-directives IS a git repo (TD_IS_GIT=true)
main if it exists, otherwise HEAD):cd "$TEAM_AI_DIRECTIVES"
git checkout -b "levelup/$(basename "$REPO_ROOT")" main 2>/dev/null || git checkout -b "levelup/$(basename "$REPO_ROOT")"
git add -A
git commit -m "Add context modules from $(basename "$REPO_ROOT")
CDRs implemented:
- CDR-001: ...
- CDR-002: ...
"
git remote get-url origin 2>/dev/null
4a. If remote "origin" exists AND gh CLI is available — push and create draft PR:
git push -u origin "levelup/$(basename "$REPO_ROOT")"
gh pr create --draft --title "Add context modules from $(basename "$REPO_ROOT")" --body "..."
4b. If remote "origin" exists but gh is NOT available — push only, tell user to open PR manually:
git push -u origin "levelup/$(basename "$REPO_ROOT")"
Report: "Pushed to origin/levelup/{project-name}. Open a PR manually at your Git host."
4c. If no remote exists — commit locally only. Report: "Committed to local branch levelup/{project-name}. Add a remote (git remote add origin <url>) and push when ready."
Case B: team-ai-directives is NOT a git repo (TD_IS_GIT=false)
Offer the user two options:
git init + commit — initialize git, create an initial commit with the scaffold, then commit the new context modules:cd "$TEAM_AI_DIRECTIVES"
git init
git add -A
git commit -m "Initial team-ai-directives scaffold"
git checkout -b "levelup/$(basename "$REPO_ROOT")"
git add -A
git commit -m "Add context modules from $(basename "$REPO_ROOT")"
Then follow steps 3–4 above (remote check).
{TEAM_AI_DIRECTIVES}. Initialize git and commit when ready."## LevelUp Implement Summary
**Project**: {project-name}
**Branch**: levelup/{project-name}
**CDRs Implemented**: N
**CDRs Skipped (Signal Gate)**: M
### Artifacts Created
| Type | Count |
|---|---|
| Rules | N |
| Personas | N |
| Examples | N |
| Skills | N |
| Constitution Changes | N |
| Evals | N |
### PR Details
**URL**: {PR-URL}
**Status**: Draft
### Next Steps
1. Review PR
2. Merge when approved
3. Run `/team-repair` after merge to re-index and validate
/levelup-clarify to resolvecreated, modified, verified, age_daysCDR.mdCDR.md first and skip the actual modules/levelup-publishAfter PR is merged in team-ai-directives, run /team-repair to:
CDR.md, .skills.json, and AGENTS.md/levelup-init or /levelup-specify
↓
/levelup-clarify
↓
/levelup-publish
↓
PR merged
↓
/team-repair --validate
After implementation, monitor the PR for review. Once merged, run /team-repair to validate the updated team AI directives.
{TEAM_AI_DIRECTIVES}/context_modules/{TEAM_AI_DIRECTIVES}/evals/ (for eval-type CDRs){TEAM_AI_DIRECTIVES}/skills/ (unless skipped).skills.json updated with new skillsCDR.md updated at {TEAM_AI_DIRECTIVES}/CDR.md$ARGUMENTS
Take tikalk/levelup-publish 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.