commit f33f21dd792490975fc7fd281fa52d5969185117 Author: Zhongwei Li Date: Sat Nov 29 17:55:18 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..fcf2226 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "session-management", + "description": "Git-native session lifecycle management with context preservation, checkpoint tracking, and seamless handoffs between coding sessions", + "version": "0.0.5", + "author": { + "name": "AnthemFlynn", + "email": "AnthemFlynn@users.noreply.github.com" + }, + "skills": [ + "./skills" + ], + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f068679 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# session-management + +Git-native session lifecycle management with context preservation, checkpoint tracking, and seamless handoffs between coding sessions diff --git a/commands/checkpoint.md b/commands/checkpoint.md new file mode 100644 index 0000000..9a0ec71 --- /dev/null +++ b/commands/checkpoint.md @@ -0,0 +1,99 @@ +--- +description: Create session checkpoint with automatic state capture +--- + +# Checkpoint Workflow + +Execute the session-management skill's checkpoint workflow to save progress. + +## Step 1: Analyze Current State + +The checkpoint manager will automatically analyze: +- Git changes (modified, added, deleted files) +- TDD metrics (if TDD mode active) +- Session metrics (time elapsed, objectives completed) + +## Step 2: Gather Optional Inputs (if desired) + +Use `AskUserQuestion` to ask if the user wants to provide additional context: + +Ask: "Would you like to add notes or create a git commit with this checkpoint?" + +Options: +- **Just save checkpoint** - Create checkpoint document only +- **Add notes** - Prompt for checkpoint notes (proceed to Question 2a) +- **Add notes and commit** - Prompt for notes and create git commit (proceed to Question 2a and 2b) +- **Commit without notes** - Skip notes, create commit with auto-generated message (proceed to Question 2b) + +### Question 2a: Checkpoint Notes (if requested) + +Ask: "What notes would you like to add to this checkpoint?" + +Options: +- **"Completed [feature/task]"** - Standard completion note +- **"Work in progress on [area]"** - WIP note +- **"Blocked on [issue]"** - Blocker note +- **Other** - Let user type custom notes + +### Question 2b: Git Commit (if requested) + +Ask: "Should we create a git commit for this checkpoint?" + +Options: +- **Auto-generate commit message** - Use checkpoint analysis to create message +- **Custom commit message** - Let user type custom message +- **Skip commit** - Just save checkpoint, no git commit + +## Step 3: Execute Checkpoint + +Based on collected inputs, execute the checkpoint command: + +```bash +cd ${CLAUDE_PLUGIN_ROOT}/skills/session-management/scripts + +# Basic checkpoint (no notes, no commit) +python session.py checkpoint + +# With notes +python session.py checkpoint --notes "[user notes]" + +# With notes and commit +python session.py checkpoint --notes "[user notes]" --commit + +# With commit and custom message +python session.py checkpoint --commit --message "[custom message]" + +# With TDD phase tracking +python session.py checkpoint --tdd-phase [RED|GREEN|REFACTOR] +``` + +The script will: +- Analyze git diff for changes +- Capture current metrics +- Generate checkpoint document +- Save to `.sessions/checkpoints/checkpoint_[timestamp].md` +- Optionally create git commit + +## Step 4: Confirm Checkpoint Saved + +Report to user: +- Checkpoint file location +- Summary of changes captured +- Git commit hash (if commit created) +- Current session progress + +--- + +## Use This Command + +At logical milestones during work: +- After completing a sub-task +- Before switching contexts +- When you want to save progress +- After each TDD cycle (RED, GREEN, REFACTOR) + +## Integration Notes + +- Integrates with **tdd-workflow** for automatic phase tracking +- Checkpoints saved to `.sessions/checkpoints/` directory +- Git commits tagged with checkpoint metadata diff --git a/commands/session-end.md b/commands/session-end.md new file mode 100644 index 0000000..a7b4247 --- /dev/null +++ b/commands/session-end.md @@ -0,0 +1,128 @@ +--- +description: End session with comprehensive handoff generation +--- + +# Session End Workflow + +Execute the session-management skill's finish workflow to create a comprehensive handoff. + +## Step 1: Create Final Checkpoint + +First, automatically create a final checkpoint to capture the current state: + +```bash +cd ${CLAUDE_PLUGIN_ROOT}/skills/session-management/scripts +python session.py checkpoint --label "session-end" +``` + +This captures all uncommitted work and current metrics. + +## Step 2: Gather Handoff Information + +Use `AskUserQuestion` to collect information for the handoff document: + +### Question 1: What Did You Accomplish? + +Ask: "What did you accomplish in this session?" + +Options: +- Analyze the session checkpoints and git commits to suggest: + - **"Completed [feature/task from objectives]"** + - **"Fixed [issues addressed]"** + - **"Implemented [components created]"** + - **"Refactored [areas improved]"** +- **Other** - Let user type custom accomplishments + +### Question 2: What Decisions Were Made? + +Ask: "Were there any important decisions or trade-offs made during this session?" + +Options: +- **"Chose [technology/approach] because [reason]"** - Technical decision +- **"Decided to defer [feature] due to [constraint]"** - Scope decision +- **"No major decisions"** - Skip this section +- **Other** - Let user type custom decisions + +### Question 3: What Should Next Session Remember? + +Ask: "What context or next steps should be documented for the next session?" + +Options: +- **"Continue with [specific task]"** - Next task note +- **"Watch out for [potential issue]"** - Warning note +- **"Remember to [action item]"** - Action reminder +- **"Review [code/docs] before proceeding"** - Review reminder +- **Other** - Let user type custom notes + +### Question 4: Git Push Options + +Ask: "Should we push commits to the remote repository?" + +Options: +- **Yes, push to remote** - Push all commits (proceed with confirmation) +- **No, keep local** - Don't push (useful for WIP) +- **Ask for confirmation first** - Show what will be pushed, then confirm + +## Step 3: Generate Handoff Document + +Based on collected inputs, execute the session end command: + +```bash +cd ${CLAUDE_PLUGIN_ROOT}/skills/session-management/scripts + +# Generate handoff and push +python session.py end --push + +# Generate handoff without push +python session.py end --no-push + +# With merge to main +python session.py end --merge-to main --push +``` + +The script will: +- Generate comprehensive handoff document with: + - Session summary (start time, duration, objectives) + - Accomplishments (from collected inputs) + - Decisions made (from collected inputs) + - Context for next session (from collected inputs) + - Metrics (commits, files changed, tests added) + - Git status (branch, uncommitted changes) +- Save to `.sessions/handoffs/handoff_[timestamp].md` +- Optionally push commits to remote +- Update session state to "ended" + +## Step 4: Confirm and Finalize + +Report to user: +- Handoff document location +- Session summary (time spent, accomplishments) +- Git status (commits pushed, branch state) +- Next session recommendations + +Optionally ask: + +Ask: "Would you like to merge this branch?" + +Options: +- **Merge to main** - Merge current branch to main +- **Merge to develop** - Merge to develop branch +- **Create pull request** - Guide PR creation +- **Keep branch** - Don't merge, keep for next session + +--- + +## Use This Command + +When ending a work session: +- End of day or before extended break +- After completing feature or fix +- Before context switching to different project +- When wrapping up and need handoff for future you or teammates + +## Integration Notes + +- Integrates with **tdd-workflow** for test metrics in handoff +- Uses checkpoint system for comprehensive state capture +- Handoffs saved to `.sessions/handoffs/` directory +- Session state preserved in `.sessions/state.json` diff --git a/commands/session-start.md b/commands/session-start.md new file mode 100644 index 0000000..4517e78 --- /dev/null +++ b/commands/session-start.md @@ -0,0 +1,135 @@ +--- +description: Start or resume coding session with AI-guided context loading +--- + +# Session Start Workflow + +Execute the session-management skill's start workflow using this step-by-step process. + +## Step 1: Generate Project Status Report + +First, generate a comprehensive project status report to understand current state: + +```bash +python ${CLAUDE_PLUGIN_ROOT}/skills/project-status-report/scripts/report.py +``` + +Or invoke the project-status-report skill if available. + +The report will show: +- Health indicators (tests, linting, coverage) +- Git status (current branch, uncommitted changes, active branches) +- Recent session summary +- Open work items (TODOs, FIXMEs, objectives) + +## Step 2: Gather User Inputs via AskUserQuestion + +Use the `AskUserQuestion` tool to collect session configuration. Ask the following questions: + +### Question 1: What to Work On + +Ask: "What would you like to work on in this session?" + +Options: +- **Resume existing work** - Continue from where you left off +- **Start new work** - Begin a new feature or task +- **Address health issues** - Fix test failures or other critical issues from the report + +### Question 2: Branch Selection + +Ask: "Which branch would you like to work on?" + +Options should include: +- All active branches from the git status (show current branch indicator and last commit date) +- **Create new branch** option + +**If user selects "Create new branch"**, proceed to Question 2a and 2b. + +#### Question 2a: Branch Type (if creating new) + +Ask: "What type of branch would you like to create?" + +Options: +- **Hotfix branch** (hotfix/...) - For urgent bug fixes +- **Feature branch** (feature/...) - For new features +- **Bugfix branch** (fix/...) - For non-urgent bug fixes +- **Other** - Custom branch prefix + +#### Question 2b: Branch Name (if creating new) + +Ask: "What should we name the branch?" + +Options: +- Suggest intelligent defaults based on: + - Branch type selected + - Health issues from report (e.g., "fix/test-failures") + - TODOs from report (e.g., "feature/oauth-integration") + - User's stated objective +- **Other** - Let user type custom name + +### Question 3: Session Objectives + +Ask: "What are your objectives for this session?" + +Options: +- Suggest objectives based on context: + - "Fix [specific health issue]" + - "Implement [TODO item]" + - "Complete [work from last session]" +- **Other** - Let user type custom objectives + +## Step 3: Execute Session Start + +Based on the collected inputs, execute the session.py script: + +```bash +cd ${CLAUDE_PLUGIN_ROOT}/skills/session-management/scripts +python session.py start [branch-name] --objective "[objectives]" +``` + +**Additional flags:** +- Add `--tdd` if objectives involve implementing features or fixing bugs +- Add `--resume` if user selected "Resume existing work" + +The script will: +- Checkout or create the specified branch +- Initialize session state in `.sessions/state.json` +- Update plugin coordination state in `.ccmp/state.json` +- Load relevant context files (claude.md, architecture docs) + +## Step 4: Load Session Context + +After session initialization: + +1. Check if `.sessions/state.json` was created successfully +2. Read any relevant claude.md files for the work area +3. Load previous session context if resuming +4. Present a summary to the user: + - Current branch + - Session objectives + - Relevant context loaded + - Next suggested actions + +## Step 5: Ready to Work + +Confirm to the user: +- Session is initialized +- Branch is ready +- Context is loaded +- Ready to begin work on stated objectives + +--- + +## Use This Command When + +- Starting work on a project after a break +- Returning after context switch between projects +- Beginning a new feature or bugfix +- Need to load full project context quickly + +## Integration Notes + +This command integrates with: +- **project-status-report** - For comprehensive health overview +- **claude-context-manager** - Auto-loads relevant claude.md files +- **tdd-workflow** - Enables TDD mode tracking if --tdd flag used diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..c045a45 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,105 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:AnthemFlynn/ccmp:plugins/session-management", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "717f716bef947623e2ae573208bdbf7d5c2c898a", + "treeHash": "841fddade57f2e447a999df435b365df614f7a544b6313477b2f74e7c9ebb2b6", + "generatedAt": "2025-11-28T10:24:51.939630Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "session-management", + "description": "Git-native session lifecycle management with context preservation, checkpoint tracking, and seamless handoffs between coding sessions", + "version": "0.0.5" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "4a69b16c77fcc61583c89fdc3bf1317bef5e8398cb20bdcece177d8fa636f431" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "7a482d185c5dc8cb3f3023f52e8a34f9f35c0a1fe9d07d4fc82cb528f64de0c3" + }, + { + "path": "commands/checkpoint.md", + "sha256": "630f45de60ca09ad9ffbe3a3e7a4d3b111e7c2250750708eae342a669489a320" + }, + { + "path": "commands/session-end.md", + "sha256": "b53f13ef8a6b86953959b862457c21d0797833cff2bdc616874068f4a2e2f866" + }, + { + "path": "commands/session-start.md", + "sha256": "014e22b9721d33cdea53e4894400cbbda13739536a616089b727de1c595a692e" + }, + { + "path": "skills/session-management/SKILL.md", + "sha256": "cc8f293fd1e611c7d350bb18d83a0fdeabe49dd07f2b2d4a7ec32c428598dc6e" + }, + { + "path": "skills/session-management/references/handoff-template.md", + "sha256": "e3ff6f85b2b39a02b5599f7124036331eaad8bef0d0296b372729a4969170de3" + }, + { + "path": "skills/session-management/references/commands.md", + "sha256": "a5f64a4b775b3466f8a11c7e7a86a6f6a71cc53207045744a0ae33757b922113" + }, + { + "path": "skills/session-management/references/config-reference.md", + "sha256": "645fa8863e0af490b8620bc7104491bb2950e2e2881eabf1aef4c49a38d039f8" + }, + { + "path": "skills/session-management/scripts/checkpoint.py", + "sha256": "5092d7e016b4f714f537cebbb4f15c2c07f219b19755b54ad072b9d1bb399933" + }, + { + "path": "skills/session-management/scripts/handoff.py", + "sha256": "7d4a64eb7f5ae8023dc13c66563382656d7d60a94822b0be1249d9eb15debe04" + }, + { + "path": "skills/session-management/scripts/session.py", + "sha256": "87e5e3fe3bd406a88fc03f07862113c07e9b417acd8546f935cc3b18ade1002a" + }, + { + "path": "skills/session-management/scripts/test_handoff.py", + "sha256": "8d3c769249f5aae1692035fdc93777223a3bcd8785195d7316a07b53e69acb76" + }, + { + "path": "skills/session-management/scripts/init_session.py", + "sha256": "154d48a5d549df61ac599835e1068068b38bcdb60e060e4b30ad18e06b03dff7" + }, + { + "path": "skills/session-management/scripts/test_checkpoint.py", + "sha256": "53bbec8d4d2fbaf4f7f755cccac84fd8baeee23fa8f510e5032397ec46286336" + }, + { + "path": "skills/session-management/assets/conventions-template.md", + "sha256": "0346227a75ebe2630a495ed2d2ccc4d0e21eff296d8b19c0d716a3a40709413c" + }, + { + "path": "skills/session-management/assets/architecture-template.md", + "sha256": "2051373aaef9b9a4fb3621e48d4333ccf3f94277067093eb07a650e72aca0e12" + }, + { + "path": "skills/session-management/assets/config-template.yaml", + "sha256": "cccb8ac956e1a2cb65d52e4678da3e9bbec81f3f783ccab7e9dd244f884f7daf" + } + ], + "dirSha256": "841fddade57f2e447a999df435b365df614f7a544b6313477b2f74e7c9ebb2b6" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/session-management/SKILL.md b/skills/session-management/SKILL.md new file mode 100644 index 0000000..d5417a9 --- /dev/null +++ b/skills/session-management/SKILL.md @@ -0,0 +1,466 @@ +--- +name: session-management +description: Git-native session lifecycle management for software development. Use when starting/resuming coding sessions, creating checkpoints, tracking objectives and blockers, generating handoffs between sessions, or needing context preservation across work sessions. Provides intelligent onboarding for AI coding agents by loading comprehensive project context. +--- + +# Session Management + +Manage coding sessions with git-native workflows, intelligent context preservation, and seamless agent onboarding. + +## Core Concept + +**Sessions = Branches + Context** + +Session management enhances git workflows by: +- Mapping branches to work sessions with objectives +- Creating enhanced commits with decision metadata +- Tracking progress, blockers, and architectural decisions +- Generating comprehensive handoffs between sessions +- Providing instant context loading for AI agents + +## Quick Start + +### Initialize in Project + +```bash +python scripts/init_session.py +``` + +Creates `.sessions/` directory with: +- `config.yaml` - Session configuration (optional) +- `checkpoints/` - Checkpoint storage +- `state.json` - Current session state + +### Core Workflows + +**Important**: All slash commands use the `AskUserQuestion` tool to gather inputs interactively. The Python scripts accept CLI arguments, so commands collect user choices via multiple-choice prompts, then execute scripts with those arguments. + +#### Session Start (`/session-start`) + +**Rapid re-immersion for both human and AI** + +```bash +/session-start +``` + +**What happens:** +1. **Project status report generated** - Health, git status, recent work, open items +2. **Interactive prompts via AskUserQuestion** - User selects what to work on, which branch, and session objectives through multiple-choice questions +3. **Branch selection** - Choose from active branches or create new (hotfix/feature/bugfix) +4. **Context loaded** - Architecture, decisions, patterns from last session +5. **Session ready** - Both human and AI fully contextualized + +**Use when:** +- Starting work on a project +- Returning after days away +- Context switching between projects + +#### Create Checkpoint (`/checkpoint`) + +**Quick save points during work** + +```bash +/checkpoint +``` + +**What happens:** +1. **Automatic capture** - Git diff, metrics, TDD cycles analyzed +2. **Interactive prompts via AskUserQuestion** - User chooses whether to add notes, create git commit, or both +3. **Checkpoint saved** - Comprehensive snapshot generated +4. **Git commit** - Optionally create commit with auto-generated or custom message + +**Use when:** +- At logical milestones +- Completing sub-tasks +- Before switching contexts + +**Examples:** +```bash +# Simple checkpoint +python scripts/session.py checkpoint --label "oauth-complete" + +# Checkpoint with notes and git commit +python scripts/session.py checkpoint --label "feature-complete" --notes "OAuth flow tested" --commit + +# With custom commit message +python scripts/session.py checkpoint --label "bugfix" --commit --message "fix: resolve auth token expiry" +``` + +#### End Session (`/session-end`) + +**Comprehensive knowledge capture and handoff** + +```bash +/session-end +``` + +**What happens:** +1. **Final checkpoint created** - Captures current state +2. **Interactive prompts via AskUserQuestion** - User provides session accomplishments, decisions made, and context for next session +3. **Handoff generated** - Full session summary with metrics and next steps +4. **Git push** - User chooses whether to push commits to remote +5. **State saved** - Ready for next session + +**Use when:** +- Finishing work session +- End of day +- Before extended break + +## Session Lifecycle + +**START** → Load full project context with status report +**WORK** → Track changes automatically in background +**CHECKPOINT** → Save progress with automatic git analysis +**END** → Generate handoff with comprehensive session summary + +## Key Features + +### 1. Objectives Management + +Track what you're trying to accomplish: + +```bash +# Add objective +python scripts/session.py objectives add "Implement OAuth2 integration" + +# Mark complete +python scripts/session.py objectives complete obj-1 + +# List all +python scripts/session.py objectives list +``` + +### 2. Blocker Tracking + +Record impediments: + +```bash +# Add blocker +python scripts/session.py blockers add "Waiting on API keys" + +# Resolve +python scripts/session.py blockers resolve blk-1 +``` + +### 3. Decision Logging + +Capture architectural decisions with context: + +```bash +# Record decision +python scripts/session.py decisions add "Using repository pattern for data access" \ + --rationale "Separates domain logic from persistence" \ + --alternatives "Active Record: Too coupled to database" +``` + +### 4. Context Queries + +Check current state: + +```bash +# Full status +python scripts/session.py status + +# Just objectives +python scripts/session.py status --objectives + +# History +python scripts/session.py history --count 10 +``` + +## Agent Onboarding + +When AI agents (like Claude Code) start, session management provides instant context: + +```python +# Automatically loads on agent start: +# - Project architecture pattern +# - Code conventions +# - Recent decisions +# - Current objectives +# - Active blockers +# - Git history analysis +# - File changes summary +``` + +Agent receives structured brief including: +- What we're building (objectives) +- How to build it (architecture, patterns, conventions) +- What's done (progress) +- What's next (next actions) +- What to watch for (blockers, TODOs) + +## Storage Structure + +``` +project/ +├── .session/ # Git-tracked, shared across team +│ ├── config.yaml # Configuration +│ ├── architecture.md # Architecture documentation +│ ├── conventions.md # Code conventions +│ └── decision-log.md # All decisions (auto-generated) +│ +└── .git/ + └── sessions/ # Local, developer-specific + └── / + ├── objectives.md + ├── blockers.md + └── context.json +``` + +**Design principle**: Shared context (architecture, conventions) is git-tracked. Personal workflow data (objectives, notes) stays local. + +## Configuration + +Edit `.session/config.yaml`: + +```yaml +session: + auto_track: true # Track file changes automatically + handoff_on_end: true # Generate handoff when ending + +context: + architecture: hexagonal # Your architecture pattern + patterns: # Patterns to enforce + - repository-pattern + - dependency-injection + +tracking: + watch_patterns: # Files to monitor + - "src/**/*.py" + - "tests/**/*.py" +``` + +## Workflows + +### Daily Development + +```bash +# Morning: Resume work +python scripts/session.py resume + +# During work: Checkpoint at milestones +python scripts/session.py checkpoint --label "api-complete" + +# Evening: End with handoff +python scripts/session.py end +``` + +### Context Switching + +```bash +# Urgent bug comes in +python scripts/session.py switch hotfix/critical-bug + +# Fix bug +python scripts/session.py checkpoint --message "Fix security issue" +python scripts/session.py end --merge-to main + +# Back to feature +python scripts/session.py resume feature/main-work +``` + +### Team Handoffs + +```bash +# Generate comprehensive handoff +python scripts/session.py end --handoff --summary + +# Next developer loads context +python scripts/session.py resume +``` + +## Enhanced Commits + +Session checkpoints create git commits with rich metadata: + +``` +feat(auth): Implement OAuth2 provider + +Completed Google OAuth flow with PKCE support. + +Session-Objectives: +- [x] OAuth provider interface +- [▶] Google OAuth (this commit) +- [ ] GitHub OAuth (next) + +Decisions: +- Using PKCE flow for enhanced security + Rationale: Protection against code interception + +Impact: +- Added: src/auth/oauth_provider.py +- Tests: +12 unit tests +- Coverage: 79% → 84% + +Session-Time: 2h 15m +``` + +## Advanced Features + +### Session Analysis + +```bash +# Analyze session health +python scripts/session.py analyze + +# Calculate velocity +python scripts/session.py analyze --velocity + +# Pattern detection +python scripts/session.py analyze --patterns +``` + +### Session History + +```bash +# Recent sessions with metrics +python scripts/session.py history --count 5 --metrics + +# Compare sessions +python scripts/session.py compare +``` + +### Reports + +```bash +# Weekly summary +python scripts/session.py report --weekly + +# Project summary +python scripts/session.py report --project --format markdown +``` + +## Bundled Resources + +### Scripts + +- **`init_session.py`** - Initialize session management in project +- **`session.py`** - Main CLI for all session operations +- **`analyze_git.py`** - Git history analysis utilities + +### References + +- **`commands.md`** - Complete command reference +- **`handoff-template.md`** - Template for session handoffs +- **`config-reference.md`** - All configuration options + +### Assets + +- **`config-template.yaml`** - Default configuration +- **`architecture-template.md`** - Architecture documentation template +- **`conventions-template.md`** - Conventions template + +## Best Practices + +**For Solo Development:** +- Start every session with objectives +- Checkpoint at logical milestones +- Record decisions when making them +- End sessions with handoffs (helps future you) + +**For Teams:** +- Commit `.session/` directory (shared context) +- Keep personal workflow local +- Link blockers to issue tracker +- Generate handoffs for transitions + +**For AI-Assisted Development:** +- Session management provides instant agent context +- No need to re-explain project structure +- Architectural patterns automatically enforced +- Decisions preserved across sessions + +## Troubleshooting + +**Session not loading?** +```bash +python scripts/session.py status --verbose +python scripts/session.py start --resume +``` + +**Need to reinitialize?** +```bash +python scripts/init_session.py --force +``` + +**View current configuration:** +```bash +cat .session/config.yaml +``` + +## CCMP Plugin Integration + +Session management **automatically integrates** with other CCMP plugins: + +### With claude-context-manager 📚 +**Auto-loads relevant context on session start:** +```bash +python scripts/session.py start feature/auth +# → Automatically loads src/auth/claude.md +# → Shows context health warnings +# → Includes patterns and gotchas in brief +``` + +**Checkpoints trigger context health checks:** +```bash +python scripts/session.py checkpoint --label "api-complete" +# → Detects src/api/ changed +# → Warns if context is stale +# → Offers: "Update context? [y/N]" +``` + +**Handoffs include context health:** +```bash +python scripts/session.py end --handoff +# → Includes context health score +# → Lists files needing updates +# → Recommends maintenance for next session +``` + +### With tdd-workflow 🧪 +**TDD mode automatically enhances sessions:** +```bash +python scripts/session.py start feature/auth --tdd +# → TDD workflow detects and activates +# → Automatic RED-GREEN-REFACTOR checkpoints +# → TDD metrics in session status +# → Test coverage tracking +``` + +**Session analysis detects TDD:** +```bash +python scripts/session.py analyze +# → Shows TDD cycles completed +# → Detects commits without tests +# → Reports discipline violations +``` + +### Integration API +Uses `.ccmp/state.json` for plugin coordination. See `lib/ccmp_integration.py` for details. + +**Developers:** Import the integration library: +```python +from lib.ccmp_integration import CCMPIntegration + +integration = CCMPIntegration() +if integration.is_active("session-management"): + session = integration.get_state("session-management") +``` + +## Integration Notes + +Session management is designed to work with: +- **Git** (required) - Source of truth for history +- **Issue Trackers** (optional) - Link blockers to tickets +- **CI/CD** (optional) - Include build status in briefings +- **Coverage Tools** (optional) - Track quality metrics + +For integration guides, see `references/integrations.md`. + +## See Also + +- **Full command reference**: See `references/commands.md` +- **Configuration options**: See `references/config-reference.md` +- **Handoff format**: See `references/handoff-template.md` +- **Integration guides**: See `references/integrations.md` diff --git a/skills/session-management/assets/architecture-template.md b/skills/session-management/assets/architecture-template.md new file mode 100644 index 0000000..fafa567 --- /dev/null +++ b/skills/session-management/assets/architecture-template.md @@ -0,0 +1,94 @@ +# Project Architecture + +## Architecture Pattern + +**Pattern**: [Hexagonal / Layered / Microservices / MVC / Clean / DDD] + +### Core Principles +- [Principle 1] +- [Principle 2] +- [Principle 3] + +## Project Structure + +``` +[Your project structure here] + +Example for hexagonal: +src/ +├── domain/ # Business logic (no external dependencies) +│ ├── models/ # Domain models +│ ├── services/ # Business services +│ └── exceptions/ # Domain exceptions +├── ports/ # Interface definitions (contracts) +│ ├── repositories/ # Data access interfaces +│ └── providers/ # External service interfaces +├── adapters/ # External integrations +│ ├── database/ # Database implementations +│ ├── api/ # External API clients +│ └── messaging/ # Message queue adapters +└── application/ # Use case orchestration + └── usecases/ # Application use cases +``` + +## Key Interfaces + +List the important interfaces/contracts in your system: + +- **[IRepository]**: [Description] +- **[IService]**: [Description] +- **[IProvider]**: [Description] + +## Architectural Decisions + +Document major architectural decisions: + +### Decision 1: [Title] +**Date**: [YYYY-MM-DD] +**Context**: [Why this was needed] +**Decision**: [What was decided] +**Rationale**: [Why this approach] + +### Decision 2: [Title] +**Date**: [YYYY-MM-DD] +**Context**: [Why this was needed] +**Decision**: [What was decided] +**Rationale**: [Why this approach] + +## Patterns & Practices + +### Design Patterns Used +- **[Pattern Name]**: [Where and why used] +- **[Pattern Name]**: [Where and why used] + +### Best Practices +- [Practice 1] +- [Practice 2] +- [Practice 3] + +## Dependencies Flow + +Describe how dependencies flow in your architecture: + +``` +[Dependency flow diagram or description] + +Example for hexagonal: +Outside → Adapters → Ports → Domain + ↑ ↓ + ← Application ←────── +``` + +## Testing Strategy + +- **Unit Tests**: [What to unit test and how] +- **Integration Tests**: [Integration boundaries] +- **E2E Tests**: [End-to-end scenarios] + +## Notes for Developers + +Additional guidance for developers working in this codebase: + +- [Important note 1] +- [Important note 2] +- [Important note 3] diff --git a/skills/session-management/assets/config-template.yaml b/skills/session-management/assets/config-template.yaml new file mode 100644 index 0000000..bd682be --- /dev/null +++ b/skills/session-management/assets/config-template.yaml @@ -0,0 +1,74 @@ +# Session Management Configuration + +session: + # Automatically track file changes during session + auto_track: true + + # Create automatic checkpoints at intervals (false = manual only) + auto_checkpoint: false + checkpoint_interval: 30m + + # Generate handoff document on session end + handoff_on_end: true + + # Archive completed sessions after N days + archive_after_days: 30 + +context: + # Primary architecture pattern for this project + # Options: hexagonal, layered, microservices, mvc, clean, ddd + architecture: hexagonal + + # Code patterns to detect and enforce + patterns: + - repository-pattern + - dependency-injection + + # Project conventions + conventions: + - type-hints-required + - docstrings-required + +tracking: + # File patterns to watch for changes + watch_patterns: + - "src/**/*.py" + - "tests/**/*.py" + - "docs/**/*.md" + + # Patterns to ignore + ignore_patterns: + - "**/__pycache__/**" + - "**/node_modules/**" + - "**/.venv/**" + - "**/dist/**" + + # Annotations to track + annotations: + - "TODO:" + - "FIXME:" + - "DECISION:" + - "BLOCKER:" + +quality: + # Minimum test coverage threshold (%) + coverage_threshold: 85 + + # Require tests for new features + require_tests: true + + # Block merge if quality thresholds not met + block_merge_on_quality: true + +display: + # Use colored terminal output + color: true + + # Verbosity level (false, true, debug) + verbose: false + + # Use emoji in output + emoji: true + + # Date/time format + date_format: "%Y-%m-%d %H:%M" diff --git a/skills/session-management/assets/conventions-template.md b/skills/session-management/assets/conventions-template.md new file mode 100644 index 0000000..8c2958f --- /dev/null +++ b/skills/session-management/assets/conventions-template.md @@ -0,0 +1,258 @@ +# Code Conventions + +## Language & Framework + +**Primary Language**: [Python / JavaScript / TypeScript / etc.] +**Version**: [Version number] +**Framework**: [Framework name and version] + +## Code Style + +### Naming Conventions + +**Variables & Functions**: +- Style: [snake_case / camelCase / PascalCase] +- Examples: `user_name`, `calculate_total`, `process_payment` + +**Classes**: +- Style: [PascalCase / snake_case] +- Examples: `UserService`, `PaymentProcessor`, `OrderRepository` + +**Constants**: +- Style: [UPPER_SNAKE_CASE / camelCase] +- Examples: `MAX_RETRIES`, `API_BASE_URL`, `DEFAULT_TIMEOUT` + +**Files**: +- Style: [snake_case / kebab-case] +- Examples: `user_service.py`, `payment-processor.ts` + +### Formatting + +- **Line Length**: [80 / 100 / 120] characters maximum +- **Indentation**: [2 / 4] spaces (no tabs) +- **String Quotes**: [single / double / either] quotes +- **Trailing Commas**: [required / optional / never] + +## Type Safety + +**Type Hints/Annotations**: [Required / Encouraged / Optional] + +```python +# Example for Python +def process_user(user_id: int, name: str) -> User: + """Process user with given ID and name.""" + pass +``` + +**Type Checking**: [Tool name: mypy / TypeScript / Flow / None] + +## Documentation + +### Docstrings + +**Style**: [Google / NumPy / Sphinx / JSDoc] + +**Required for**: +- [ ] Public functions +- [ ] Public classes +- [ ] Modules +- [ ] Complex algorithms + +**Example**: +```python +def calculate_total(items: List[Item], tax_rate: float) -> Decimal: + """ + Calculate total price including tax. + + Args: + items: List of items to total + tax_rate: Tax rate as decimal (e.g., 0.08 for 8%) + + Returns: + Total price including tax + + Raises: + ValueError: If tax_rate is negative + """ + pass +``` + +### Comments + +**When to Comment**: +- Complex algorithms +- Non-obvious business logic +- Workarounds or hacks +- TODOs and FIXMEs + +**What NOT to Comment**: +- Self-explanatory code +- What code does (let code be self-documenting) +- Commented-out code (delete instead) + +## Testing + +### Test Coverage + +- **Minimum Coverage**: [85 / 90 / 95]% +- **New Code Coverage**: [90 / 95 / 100]% + +### Test Organization + +``` +tests/ +├── unit/ # Unit tests +│ └── test_[module].py +├── integration/ # Integration tests +│ └── test_[feature].py +└── e2e/ # End-to-end tests + └── test_[scenario].py +``` + +### Test Naming + +Pattern: `test_[what]_[condition]_[expected]` + +Examples: +- `test_user_creation_with_valid_data_succeeds` +- `test_payment_processing_with_insufficient_funds_raises_error` +- `test_order_total_calculation_with_discount_returns_correct_amount` + +### Test Structure + +```python +def test_something(): + # Arrange - Set up test data + user = User(name="John") + + # Act - Perform the action + result = process_user(user) + + # Assert - Verify results + assert result.processed == True +``` + +## Error Handling + +### Exception Handling + +- **Custom Exceptions**: [Required / Optional] for domain errors +- **Logging**: [Always / Sometimes / Never] log exceptions +- **Re-raising**: [Wrap / Re-raise / Handle] exceptions appropriately + +**Example**: +```python +try: + result = risky_operation() +except SpecificError as e: + logger.error(f"Operation failed: {e}") + raise DomainError("User-friendly message") from e +``` + +## Git Conventions + +### Commit Messages + +**Format**: [Conventional Commits / Custom / Free-form] + +``` +(): + + + +