LogoSkills

session:wrap

Auto-update .claude/ documents on session end

항ëŠĐë‚īėšĐ
Invoke/session:wrap
Aliases/wrap, /sw
Categorypetmedi-automation
Complexitymedium

/session:wrap#

Auto-reflect content learned during the session into .claude/ directory documents

Triggers#

  • Just before session end
  • After discovering important patterns/rules
  • When new automatable tasks are discovered
  • When document updates are needed

Usage#

# Full session analysis and document update
/session:wrap

# Update specific area only
/session:wrap --scope rules      # Rules only
/session:wrap --scope commands   # Commands only
/session:wrap --scope agents     # Agents only

# Dry run (preview changes) - recommended
/session:wrap --dry-run

Recommended: Use --dry-run on first use to preview changes. You can review what content will be added/modified before actual file modification.


Execution Flow (2 Phases)#

┌─────────────────────────────────────────────────────────────────┐
│                    /session:wrap                                │
├─────────────────────────────────────────────────────────────────â”Ī
│                                                                 │
│  ═══════════════════════════════════════════════════════════   │
│  ║ Phase 1: Parallel Analysis (4 Agents)                     ║   │
│  ═══════════════════════════════════════════════════════════   │
│                                                                 │
│  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌────────────┐│
│  │ doc-updater │ │ automation  │ │ learning    │ │ followup   ││
│  │   Agent     │ │   -scout    │ │ -extractor  │ │ -suggester ││
│  └──────┮──────┘ └──────┮──────┘ └──────┮──────┘ └─────┮──────┘│
│         │               │               │              │        │
│         ▾               ▾               ▾              ▾        │
│  ┌────────────────────────────────────────────────────────────┐│
│  │                   Collect Analysis Results                 ││
│  └────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ═══════════════════════════════════════════════════════════   │
│  ║ Phase 2: Sequential Processing (1 Agent)                  ║   │
│  ═══════════════════════════════════════════════════════════   │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │             duplicate-checker Agent                      │   │
│  │    - Duplicate content check                             │   │
│  │    - Conflict resolution                                 │   │
│  │    - Final document cleanup                              │   │
│  └─────────────────────────────────────────────────────────┘   │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │                  Output Result Summary                    │   │
│  └─────────────────────────────────────────────────────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Phase 1: Parallel Analysis Agents#

1. doc-updater Agent#

Update CLAUDE.md and related documents based on session content

Analysis Targets:

  • Newly discovered coding conventions
  • Added project settings
  • Changed architecture patterns
  • New dependencies/packages

Output:

updates:
  - file: CLAUDE.md
    section:  " ## Architecture and Structure " 
     action: append
    content:  " New architecture pattern description... " 
   - file: .claude/rules/naming.md
    section:  " ### Naming Rules " 
     action: update
    content:  " Updated naming rules... "

2. automation-scout Agent#

Detect new automatable patterns

Analysis Targets:

  • Repetitively performed tasks
  • Manually handled tasks that could be pattern-ized
  • Tasks that could become new skills

Output:

automatable_patterns:
  - pattern:  " Always add State when adding BLoC event " 
     frequency: 3
    suggestion:  " Recommend creating bloc-event-state-pair skill " 
   - pattern:  " Always add same imports after test file creation " 
     frequency: 5
    suggestion:  " Add auto-import to test-template skill "

3. learning-extractor Agent#

Extract rules/patterns learned during the session

Analysis Targets:

  • Modified code patterns
  • Resolved errors and their solutions
  • Preferences learned from user feedback
  • Project-specific rules

Output:

learnings:
  - type: rule
    category:  " Code style " 
     content:  " Actively use dot shorthand (.start, .center, etc.) " 
     evidence:  " User pointed out unnecessary full type name usage " 
   - type: pattern
    category:  " BLoC " 
     content:  " isClosed check required after await " 
     evidence:  " Fixed multiple times due to lint errors "

4. followup-suggester Agent#

Suggest follow-up tasks

Analysis Targets:

  • Incomplete TODOs
  • Mentioned improvements
  • Discovered technical debt
  • Tasks for next session

Output:

followups:
  - priority: high
    task:  " Achieve 80% test coverage for console_author_management " 
     reason:  " Currently 45% - missing tests for key features " 
   - priority: medium
    task:  " Optimize author search API " 
     reason:  " Takes 2+ seconds for 100+ records "

Phase 2: Sequential Processing Agent#

5. duplicate-checker Agent#

Duplicate content check and cleanup

Processing Content:

  • Duplicate check of Phase 1 results
  • Conflict resolution with existing documents
  • Consistency verification
  • Apply final changes

Output:

deduplication_result:
  removed_duplicates: 2
  merged_entries: 1
  conflicts_resolved: 0
  final_changes:
    - file: CLAUDE.md
      lines_added: 15
      lines_removed: 3
    - file: .claude/rules/bloc-patterns.md
      lines_added: 8
      lines_removed: 0

Detailed Implementation#

Main Execution Logic#

async function sessionWrap(options: WrapOptions) {
  // Phase 1: Parallel analysis
  const [docUpdates, automations, learnings, followups] = await Promise.all([
    Task({
      subagent_type:  " session-doc-updater " ,
      prompt:  " Analyze session conversation content to suggest document updates " ,
    }),
    Task({
      subagent_type:  " session-automation-scout " ,
      prompt:  " Detect automatable patterns " ,
    }),
    Task({
      subagent_type:  " session-learning-extractor " ,
      prompt:  " Extract learned rules/patterns " ,
    }),
    Task({
      subagent_type:  " session-followup-suggester " ,
      prompt:  " Suggest follow-up tasks " ,
    }),
  ]);

  // Phase 2: Sequential processing
  const finalResult = await Task({
    subagent_type:  " session-duplicate-checker " ,
    prompt: `
      Review the following Phase 1 results and resolve duplicates/conflicts:

      ## Doc Updates
      ${JSON.stringify(docUpdates)}

      ## Automations
      ${JSON.stringify(automations)}

      ## Learnings
      ${JSON.stringify(learnings)}

      ## Followups
      ${JSON.stringify(followups)}
    `,
  });

  // Output results
  displayWrapSummary(finalResult);
}

Output Format#

Progress#

╔════════════════════════════════════════════════════════════════╗
║  /session:wrap Progress                                        ║
╠════════════════════════════════════════════════════════════════â•Ģ
║                                                                ║
║  Phase 1: Parallel Analysis [████████████░░░░] 75%             ║
║                                                                ║
║  ✅ doc-updater: 3 document updates suggested                  ║
║  ✅ automation-scout: 2 automation patterns found              ║
║  🔄 learning-extractor: Analyzing...                           ║
║  âģ followup-suggester: Waiting                                ║
║                                                                ║
╚════════════════════════════════════════════════════════════════╝

On Completion#

╔════════════════════════════════════════════════════════════════╗
║  Session Wrap Complete                                         ║
╠════════════════════════════════════════════════════════════════â•Ģ
║                                                                ║
║  📝 Document Updates                                           ║
║  ├── CLAUDE.md: +15 lines (coding conventions added)           ║
║  ├── .claude/rules/bloc-patterns.md: +8 lines                 ║
║  └── .claude/commands/session/wrap.md: newly created           ║
║                                                                ║
║  ðŸĪ– Automation Suggestions                                     ║
║  ├── Recommend creating bloc-event-state-pair skill            ║
║  └── Recommend adding test-template auto-import                ║
║                                                                ║
║  📚 Learned Content                                            ║
║  ├── [Rule] Actively use dot shorthand                         ║
║  ├── [Rule] isClosed check required after await                ║
║  └── [Pattern] ZenHub issueTypeId must be specified            ║
║                                                                ║
║  📋 Follow-up Tasks                                            ║
║  ├── [High] Achieve 80% test coverage                          ║
║  └── [Medium] Optimize author search API                       ║
║                                                                ║
║  🔄 Duplicates removed: 2                                      ║
║  ⚠ïļ Conflicts resolved: 0                                      ║
║                                                                ║
╚════════════════════════════════════════════════════════════════╝

Target Files#

Analysis Targets#

PathDescription
CLAUDE.mdProject main guide
.claude/rules/**/*.mdCoding rules
.claude/commands/**/*.mdSkill/agent definitions
.claude/settings.local.jsonLocal settings

Output Targets#

PathDescription
CLAUDE.mdConvention, architecture updates
.claude/rules/New rule file creation
.claude/commands/New skill/agent creation
.claude/session-logs/Session summary storage (optional)

Options#

OptionDefaultDescription
--scopeallAnalysis scope (all/rules/commands/agents)
--dry-runfalsePreview changes only
--auto-commitfalseAuto-commit changes
--skip-duplicatesfalseSkip duplicate check

  • session-doc-updater - Document update analysis
  • session-automation-scout - Automation pattern detection
  • session-learning-extractor - Learned content extraction
  • session-followup-suggester - Follow-up task suggestions
  • session-duplicate-checker - Duplicate check and cleanup

Context Passing#

How sub-agents access session conversation content:

Auto Context (default)#

Claude Code's Task tool auto-passes current conversation context to general-purpose agents. Sub-agents analyze by referencing previous conversation content.

// Context auto-included on agent call
Task({
  subagent_type:  " Explore " ,  // general-purpose type
  prompt:  " Extract rules learned during session " ,
  // Previous conversation content auto-passed to agent
});

Explicit Context Passing#

When specific information needs to be explicitly passed:

Task({
  subagent_type:  " session-learning-extractor " ,
  prompt: `
    ## Session Info to Analyze

    ### Modified Files
    - ${modifiedFiles.join( ' \n-  ' )}

    ### User Feedback
    - ${userFeedbacks.join( ' \n-  ' )}

    ### Errors Encountered
    - ${errors.join( ' \n-  ' )}

    Extract learned rules/patterns based on the above information.
  `,
});

Context Limitations#

ItemAccessibleNotes
Current session conversationOAuto-passed
Previous session conversationXIsolated between sessions
File systemOVia Read, Glob, Grep tools
Git historyOVia Bash tool

Key Rules#

  1. Non-destructive Updates: Prefer additions/modifications over deleting existing content
  2. Evidence-based: State session-based evidence for all changes
  3. Maintain Consistency: Maintain consistency with existing document style
  4. Prevent Duplicates: Prevent duplicate content additions
  5. User Confirmation: Apply important changes only after user confirmation