From session-orchestrator
Reconciles session learnings into .claude/rules/ entries on demand via /reconcile. Uses same engine as automatic session-end phase. Proposes rules for operator approval before writing.
How this skill is triggered — by the user, by Claude, or both
Slash command
/session-orchestrator:reconcilesonnetThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> **Platform Note:** State files use the platform's native directory: `.claude/` (Claude Code), `.codex/` (Codex CLI), or `.cursor/` (Cursor IDE). Shared metrics live in `.orchestrator/metrics/`. See `skills/_shared/platform-tools.md`.
Platform Note: State files use the platform's native directory:
.claude/(Claude Code),.codex/(Codex CLI), or.cursor/(Cursor IDE). Shared metrics live in.orchestrator/metrics/. Seeskills/_shared/platform-tools.md.
On-demand version of the session-end Phase 3.6.8 reconciliation flow. Turns eligible learnings
from .orchestrator/metrics/learnings.jsonl into proposed .claude/rules/<slug>.md entries,
presenting each batch of 4 to the coordinator via AUQ multiSelect for operator approval before
any file is written. Advisory-only — rules are NEVER auto-applied.
emitter.mjs) throws
on any eligible learning that would produce an alwaysApply: true rule — the engine
structurally cannot emit always-on rules. This invariant is enforced upstream, not by
this skill..claude/rules/. runReconcile computes proposals and records
them in the idempotency sidecar only. The only module that writes .claude/rules/ is
writer.mjs, and only AFTER the operator approves proposals via AUQ.reconcile.enabled gates the AUTOMATIC session-end phase only. /reconcile is an
on-demand command and runs regardless of reconcile.enabled. It still honours
rule-expiry-days and confidence-floor from the reconcile config block.Read skills/_shared/bootstrap-gate.md and execute the gate check. If the gate is CLOSED,
invoke skills/bootstrap/SKILL.md and wait for completion before proceeding. If the gate
is OPEN, continue to Phase 1.
Read and parse Session Config per skills/_shared/config-reading.md. Store result as $CONFIG.
Extract the reconcile block from $CONFIG:
# rule-expiry-days defaults to EMPTY (not a number) so the engine falls back to
# its per-type TTL (deriveExpiresAt, default 60d). A numeric override forces flat
# N-day expiry — matching the `null` default of the reconcile: config resolver.
RULE_EXPIRY_DAYS=$(echo "$CONFIG" | jq -r '.reconcile["rule-expiry-days"] // empty')
CONFIDENCE_FLOOR=$(echo "$CONFIG" | jq -r '.reconcile["confidence-floor"] // 0.5')
RECONCILE_MODE=$(echo "$CONFIG" | jq -r '.reconcile.mode // "warn"')
When RULE_EXPIRY_DAYS is empty, pass ruleExpiryDays: undefined to runReconcile so the engine uses its per-type TTL. Defaults when the reconcile block is absent or a field is missing:
rule-expiry-days: empty → per-type TTL (deriveExpiresAt, default 60d). Preserves FA2 behaviour; matches the null resolver default.confidence-floor: 0.5mode: warn (enum off | warn)Note: reconcile.enabled is intentionally NOT checked — this on-demand command always runs.
Check $ARGUMENTS for --dry-run:
DRY_RUN=false
if echo "$ARGUMENTS" | grep -q -- '--dry-run'; then
DRY_RUN=true
fi
Resolve $PLUGIN_ROOT per skills/_shared/config-reading.md (the standard resolution chain:
$CLAUDE_PLUGIN_ROOT → $CODEX_PLUGIN_ROOT → $CURSOR_RULES_DIR → common install locations).
runReconcileimport { runReconcile } from '$PLUGIN_ROOT/scripts/lib/reconcile/engine.mjs';
const { proposals, rejected, summary, error } = await runReconcile({
repoRoot, // absolute path from git rev-parse --show-toplevel
ruleExpiryDays: RULE_EXPIRY_DAYS, // empty → undefined → engine per-type TTL
now: new Date(),
dryRun: DRY_RUN, // true → engine touches no disk (no idempotency sidecar write)
});
// The engine does NOT apply a confidence floor — it proposes every eligible
// learning and carries each one's `confidence` through. `confidence-floor` is a
// DELIVERY gate: filter proposals here before the sidecar + AUQ (mirrors
// session-end Phase 3.6.8). Use `surfaced` everywhere "proposals" appears below.
const surfaced = proposals.filter((p) => typeof p.confidence === 'number' && p.confidence >= CONFIDENCE_FLOOR);
runReconcile NEVER throws — a top-level error populates result.error instead.
If error is present, surface it to the user and abort:
"Reconcile engine error:
<error>. Check.orchestrator/metrics/learnings.jsonland retry."
If summary.totalLearnings === 0:
"No learnings found in
.orchestrator/metrics/learnings.jsonl. Run/evolve analyzefirst to extract session patterns." Exit cleanly.
If summary.eligible === 0 (learnings exist but none are eligible — already proposed,
or wrong learning type — eligibility is type/file_paths-based, NOT confidence-based):
"No eligible learnings for rule proposals (total:
summary.totalLearnings, already proposed or ineligible type: all). Run more sessions to accumulate evidence." Exit cleanly. Optionally list the rejection reasons fromrejected[](fieldreason) as an informational table.
If summary.eligible > 0 but surfaced.length === 0 (proposals exist but ALL fall below
confidence-floor):
"No proposals above the confidence floor (
CONFIDENCE_FLOOR). Lowerreconcile.confidence-flooror run more sessions so the underlying learnings accrue confidence." Exit cleanly.
If summary.proposed === 0 but summary.eligible > 0 (emit/render failures consumed all
candidates — unusual):
"Engine produced 0 proposals from N eligible learnings. See rejection log." List
rejected[].reasonand exit.
Only when DRY_RUN=true.
Print the proposals in a readable table. Do NOT write the sidecar, do NOT render an AUQ.
## Reconcile — Dry Run (N proposals, M rejected)
| # | Slug | Confidence | Learning Key | Rule Path |
|---|------|-----------|-------------|-----------|
| 1 | <slug> | 0.72 | <learningKey> | .claude/rules/<slug>.md |
| 2 | ... | ... | ... | ... |
Rejected (not eligible for proposal):
| Learning Key | Reason |
|-------------|--------|
| <key> | <reason> |
Re-run without --dry-run to enter the approval flow.
Exit after printing. Do not proceed to Phase 4.
Write the proposals to .orchestrator/metrics/reconcile-pending.md as a human-readable
record before presenting the AUQ. This sidecar is informational only — it lets the operator
see the full proposal set in an editor alongside the AUQ prompt.
# Reconcile Pending — <ISO date>
Generated by `/reconcile` on <timestamp>. N proposals, M rejected.
## Proposals
| # | Slug | Confidence | Learning Key | Rendered Rule Path |
|---|------|-----------|-------------|-------------------|
| 1 | <slug> | 0.72 | <key> | .claude/rules/<slug>.md |
...
## Rejected
| Learning Key | Type | Reason |
|-------------|------|--------|
| <key> | <type> | <reason> |
...
Write via standard file write (not atomic, not lock-protected — this is a disposable sidecar, not a critical artifact).
Present proposals to the operator in batches of 4. Mirror the session-end Phase 3.6.3 / 3.6.8 multiSelect pattern exactly.
For each batch (proposals sliced into groups of 4):
AskUserQuestion({
questions: [{
question: "Which rule proposals should be written to .claude/rules/? (batch K of N)",
header: "Reconcile — Approve Rule Proposals",
options: [
{
label: "<slug>.md (confidence: 0.72)",
description: "Learning: <learningKey> | Path: .claude/rules/<slug>.md | <first 100 chars of rendered content>"
},
...up to 4 options per batch...
{
label: "Skip all in this batch",
description: "Decline all proposals in this batch — they are archived to the rejected log."
}
],
multiSelect: true
}]
})
Collect responses across all batches:
approved[]rejected_by_operator[]Codex CLI fallback: AskUserQuestion is unavailable in subagents and on Codex CLI (AUQ-004). In those contexts, present proposals as a numbered Markdown list and ask the operator to reply with the numbers they wish to approve.
writeApprovedRulesimport { writeApprovedRules } from '$PLUGIN_ROOT/scripts/lib/reconcile/writer.mjs';
const { written, archived, errors } = await writeApprovedRules({
approved: approved, // proposals the operator approved
rejected: rejected_by_operator, // proposals the operator declined
repoRoot,
sessionId: currentSessionId, // informational; from STATE.md or 'manual'
});
writeApprovedRules NEVER throws — per-item failures are collected in errors[].
If errors.length > 0, surface each error to the operator:
"Warning:
Nrule(s) failed to write:<error list>. Successfully written:written. Archived:archived."
Log each error but do NOT abort — partial success is acceptable.
## Reconcile Complete
- Written: <written> rule file(s) to .claude/rules/
- Archived: <archived> declined proposal(s) to .orchestrator/reconcile.rejected.log
- Errors: <errors.length> (see warnings above, if any)
New rules take effect immediately — they are loaded by the wave-executor's rule-loader
on the next wave dispatch.
If written === 0 and approved.length === 0:
"No proposals approved. No rules written."
writeApprovedRules before the operator has confirmed via AUQ — this is the
only write-protection gate for .claude/rules/.dryRun: false to runReconcile and then skip the AUQ — the idempotency
sidecar is written during the engine run; writing rules without AUQ confirmation would create
an inconsistency between the sidecar and the actual rule files.errors[] from writeApprovedRules — per-item isolation must not
silently swallow failures.confidence-floor and rule-expiry-days from Session Config reconcile
block — the engine reads these, but the skill must pass them explicitly..claude/rules/ without AUQ operator confirmation.reconcile.enabled — that flag gates the automatic session-end phase, not
this on-demand command.alwaysApply: true — the engine structurally prevents
it, but the reviewer should reject any proposal that would produce an always-on rule.--dry-run is passed — the entire AUQ + write flow
must be bypassed.runReconcile failures as fatal — check the error field and surface it,
then exit cleanly.npx claudepluginhub kanevry/session-orchestrator --plugin session-orchestratorExtracts session patterns into reusable learnings with analyze, review, and list modes. Manages .orchestrator/metrics/learnings.jsonl.
Extract conventions and implicit knowledge from session data into .claude/rules/local/ files. USE WHEN repeated patterns are found across sessions.
Distill context (research, recon, learnings) into evidence-anchored rules routed to automation shapes. Use when a finished artifact should become skills, gates, or beads.