| íëŠĐ | ëīėĐ |
|---|---|
| Invoke | /session:wrap |
| Aliases | /wrap, /sw |
| Category | petmedi-automation |
| Complexity | medium |
/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-runon 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#
| Path | Description |
|---|---|
CLAUDE.md | Project main guide |
.claude/rules/**/*.md | Coding rules |
.claude/commands/**/*.md | Skill/agent definitions |
.claude/settings.local.json | Local settings |
Output Targets#
| Path | Description |
|---|---|
CLAUDE.md | Convention, architecture updates |
.claude/rules/ | New rule file creation |
.claude/commands/ | New skill/agent creation |
.claude/session-logs/ | Session summary storage (optional) |
Options#
| Option | Default | Description |
|---|---|---|
--scope | all | Analysis scope (all/rules/commands/agents) |
--dry-run | false | Preview changes only |
--auto-commit | false | Auto-commit changes |
--skip-duplicates | false | Skip duplicate check |
Related Agents#
session-doc-updater- Document update analysissession-automation-scout- Automation pattern detectionsession-learning-extractor- Learned content extractionsession-followup-suggester- Follow-up task suggestionssession-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#
| Item | Accessible | Notes |
|---|---|---|
| Current session conversation | O | Auto-passed |
| Previous session conversation | X | Isolated between sessions |
| File system | O | Via Read, Glob, Grep tools |
| Git history | O | Via Bash tool |
Key Rules#
- Non-destructive Updates: Prefer additions/modifications over deleting existing content
- Evidence-based: State session-based evidence for all changes
- Maintain Consistency: Maintain consistency with existing document style
- Prevent Duplicates: Prevent duplicate content additions
- User Confirmation: Apply important changes only after user confirmation