Back to list
rjmurillo

session-migration

by rjmurillo

Multi-agent system for software development

5🍴 0📅 Jan 24, 2026

SKILL.md


name: session-migration description: Migrate session logs from markdown to JSON format. Use when PRs contain markdown session logs that need conversion to the new JSON schema, or when batch-migrating historical sessions. license: MIT version: 1.0.0 model: claude-sonnet-4-5 metadata: domains: - session-protocol - migration - data-transformation type: utility inputs: - markdown-session-logs - directory-path outputs: - json-session-logs

Session Migration Skill

Converts markdown session logs to JSON format for deterministic validation.


Quick Start

# Migrate single file
pwsh .claude/skills/session-migration/scripts/Convert-SessionToJson.ps1 -Path ".agents/sessions/.agents/sessions/2026-01-09-session-385.json"

# Migrate all sessions in directory
pwsh .claude/skills/session-migration/scripts/Convert-SessionToJson.ps1 -Path ".agents/sessions/"

# Dry run to preview changes
pwsh .claude/skills/session-migration/scripts/Convert-SessionToJson.ps1 -Path ".agents/sessions/" -DryRun

# Force overwrite existing JSON
pwsh .claude/skills/session-migration/scripts/Convert-SessionToJson.ps1 -Path ".agents/sessions/" -Force

Triggers

Use this skill when:

  • migrate session logs - Convert markdown to JSON
  • convert sessions to JSON - Format migration
  • PR has old markdown sessions - In-flight PR migration
  • session validation failing - Regex issues with markdown format
  • batch migrate sessions - Historical log conversion

Context

Why JSON?

Markdown session logs required fragile regex patterns to validate:

  • **Branch**: vs Branch: vs Starting Branch:
  • Table parsing with varied column orders
  • Checkbox detection across different formats

JSON provides:

  • Deterministic key-based validation
  • Schema enforcement
  • No regex, no fuzzy matching
  • Clear structure for tooling

Schema Location

JSON sessions follow the schema at:

.agents/schemas/session-log.schema.json

Validator

JSON sessions are validated by:

scripts/Validate-SessionJson.ps1

Process

┌─────────────────────────────────────────────────────────┐
│ 1. INPUT                                                │
│    Markdown session log (.md)                           │
│    OR directory of .md files                            │
└─────────────────────────────────────────────────────────┘
                    │
                    ▼
┌─────────────────────────────────────────────────────────┐
│ 2. PARSE                                                │
│    • Extract session number from filename               │
│    • Extract date from filename                         │
│    • Find branch, commit, objective in content          │
│    • Parse checklist tables for completion status       │
└─────────────────────────────────────────────────────────┘
                    │
                    ▼
┌─────────────────────────────────────────────────────────┐
│ 3. TRANSFORM                                            │
│    • Build session object (number, date, branch, etc.)  │
│    • Build protocolCompliance object                    │
│    • Map checkbox [x] to complete: true                 │
│    • Extract evidence from table cells                  │
└─────────────────────────────────────────────────────────┘
                    │
                    ▼
┌─────────────────────────────────────────────────────────┐
│ 4. OUTPUT                                               │
│    Write .json file alongside .md                       │
│    (same name, different extension)                     │
└─────────────────────────────────────────────────────────┘

JSON Structure

{
  "session": {
    "number": 385,
    "date": "2026-01-09",
    "branch": "feat/session-init-skill",
    "startingCommit": "abc1234",
    "objective": "Session protocol validation improvements"
  },
  "protocolCompliance": {
    "sessionStart": {
      "serenaActivated": { "level": "MUST", "complete": true, "evidence": "Tool output" },
      "handoffRead": { "level": "MUST", "complete": true, "evidence": "Content in context" }
    },
    "sessionEnd": {
      "checklistComplete": { "level": "MUST", "complete": true, "evidence": "All [x] checked" },
      "validationPassed": { "level": "MUST", "complete": true, "evidence": "Exit code 0" }
    }
  },
  "workLog": [],
  "endingCommit": "",
  "nextSteps": []
}

Parameters

ParameterTypeRequiredDescription
-PathstringYesPath to .md file or directory
-ForceswitchNoOverwrite existing .json files
-DryRunswitchNoPreview without writing files

Output

The script returns an array of migrated file paths (string[]) and prints a summary:

=== Migration Summary ===
Migrated: 356
Skipped (JSON exists): 0
Failed: 0

Exit Codes

CodeMeaningAction
0SuccessAll files migrated or skipped (expected behavior)
1FailureOne or more files failed migration (check error output)

Return Value

# Returns array of paths to migrated JSON files
$migratedPaths = & .claude/skills/session-migration/scripts/Convert-SessionToJson.ps1 -Path ".agents/sessions/"
$migratedPaths | ForEach-Object { Write-Host "Created: $_" }

PR Migration Workflow

For PRs with in-flight markdown sessions:

  1. Check for markdown sessions in PR:

    git diff origin/main --name-only | grep -E '\.agents/sessions/.*\.md$'
    
  2. Run migration:

    pwsh .claude/skills/session-migration/scripts/Convert-SessionToJson.ps1 -Path ".agents/sessions/"
    
  3. Validate migrated sessions:

    Get-ChildItem .agents/sessions/*.json | ForEach-Object {
      pwsh scripts/Validate-SessionJson.ps1 -SessionLogPath $_.FullName
    }
    
  4. Commit both formats (for transition period):

    git add .agents/sessions/*.json
    git commit -m "chore(session): migrate session logs to JSON format"
    

Checklist Mapping

The migration script maps markdown checklist patterns to JSON keys.

Session Start Items

Regex PatternJSON KeyLevel
activate_projectserenaActivatedMUST
initial_instructionsserenaInstructionsMUST
HANDOFF\.mdhandoffReadMUST
Create.*session.*log|session.*log.*exist|this.*filesessionLogCreatedMUST
skill.*scriptskillScriptsListedMUST
usage-mandatoryusageMandatoryReadMUST
CONSTRAINTSconstraintsReadMUST
memormemoriesLoadedMUST
verify.*branch|branch.*verif|declare.*branchbranchVerifiedMUST
not.*main|Confirm.*mainnotOnMainMUST
git.*statusgitStatusVerifiedSHOULD
starting.*commit|Note.*commitstartingCommitNotedSHOULD

Session End Items

Regex PatternJSON KeyLevel
Complete.*session.*log|session.*log.*complete|all.*sectionchecklistCompleteMUST
HANDOFF.*read-only|Update.*HANDOFFhandoffNotUpdatedMUST NOT
Serena.*memory|Update.*memory|memory.*updatserenaMemoryUpdatedMUST
markdownlint|markdown.*lint|Run.*lintmarkdownLintRunMUST
Commit.*change|change.*commitchangesCommittedMUST
Validate.*Session|validation.*pass|Route.*qavalidationPassedMUST
PROJECT-PLAN|task.*checkboxtasksUpdatedSHOULD
retrospectiveretrospectiveInvokedSHOULD

Troubleshooting

JSON already exists

Use -Force to overwrite:

pwsh .claude/skills/session-migration/scripts/Convert-SessionToJson.ps1 -Path ".agents/sessions/" -Force

Some sessions fail validation after migration

Expected for genuinely incomplete sessions. The migration preserves the actual state of checkboxes. Review failed sessions manually.

Pattern not detected

If a checklist item isn't detected, the markdown format may be non-standard. The script uses flexible regex but edge cases exist. Update the Find-ChecklistItem function patterns if needed.


Skills

SkillPurpose
session-initCreate new sessions in JSON format
session-log-fixerFix validation failures

Schema and Validation

ResourceLocationPurpose
JSON Schema.agents/schemas/session-log.schema.jsonDefines required structure
JSON Validatorscripts/Validate-SessionJson.ps1Validates migrated JSON files
Legacy Validatorscripts/Validate-SessionJson.ps1Validates markdown (deprecated)

Architecture

  • ADR-014: Distributed handoff architecture (context for migration)

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

0/5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon