From cc-aid
Automatically summarize the current Claude Code session and generate a meaningful session name with 20-30 words
How this skill is triggered — by the user, by Claude, or both
Slash command
/cc-aid:session-summaryThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Automatically analyze the current Claude Code session conversation, generate a comprehensive summary, and suggest/apply a meaningful session name (20-30 words) based on the key activities and topics discussed.
Automatically analyze the current Claude Code session conversation, generate a comprehensive summary, and suggest/apply a meaningful session name (20-30 words) based on the key activities and topics discussed.
Use this skill when:
Don't use when:
claude-md-management:revise-claude-md instead)1. Read conversation history
↓
2. Identify key topics and activities
↓
3. Extract significant outcomes
↓
4. Generate summary
↓
5. Suggest descriptive session name (20-30 words)
↓
6. Apply rename (if user approves)
First, determine the session storage location:
# Claude Code sessions are typically stored in:
# ~/.claude/sessions/ or similar location
# List recent session files
ls -lt ~/.claude/sessions/ | head -10
The current session can be identified by:
# Check for session-related environment variables
env | grep -i claude | grep -i session
# Find most recent session file
find ~/.claude/sessions -type f -name "*.json" -o -name "*.jsonl" | xargs ls -t | head -1
Extract and analyze the conversation from the current context:
**Analysis Framework:**
1. **Topics Discussed:**
- What subjects/technologies were discussed?
- What problems were being solved?
- What features were being developed?
2. **Actions Taken:**
- Files created/modified/deleted
- Commands executed
- Tools/skills invoked
- Git operations performed
3. **Key Outcomes:**
- What was accomplished?
- What decisions were made?
- What problems were solved?
- What remained unfinished?
4. **Context & Domain:**
- Which project/repository?
- Which programming language?
- Which framework/technology?
Create a structured summary:
# Session Summary
## 📋 Overview
[One-paragraph summary of the entire session]
## 🎯 Key Topics
- Topic 1: [description]
- Topic 2: [description]
- Topic 3: [description]
## ✅ Accomplishments
1. [Achievement 1 with details]
2. [Achievement 2 with details]
3. [Achievement 3 with details]
## 📝 Files Changed
- Created: [list of new files]
- Modified: [list of modified files]
- Deleted: [list of deleted files]
## 🔧 Tools & Skills Used
- [Skill/tool 1]: [purpose]
- [Skill/tool 2]: [purpose]
## 💡 Key Decisions
- [Decision 1 and rationale]
- [Decision 2 and rationale]
## 🚧 Remaining Work
- [ ] [Task 1]
- [ ] [Task 2]
## 🏷️ Suggested Tags
[Technology, Domain, Type, etc.]
Create a descriptive, detailed session name that captures the full scope of the session:
Naming Convention:
[Detailed description of work including actions, technologies, and context]
Target: 20-30 words
Format: Complete sentences or detailed phrases
Include: What, Why, How, Technologies, Context
Examples (20-30 words):
✅ "Created comprehensive session-summary skill for Claude Code enabling automatic conversation analysis, structured summary generation, and intelligent session naming with detailed implementation documentation and examples"
✅ "Debugged and fixed critical authentication race condition in Express API middleware affecting production OAuth flows by implementing proper async lock mechanism and comprehensive unit tests"
✅ "Implemented complete OVN-Kubernetes topology visualization feature using D3.js force-directed graphs, including database query optimization, real-time updates, and interactive network exploration capabilities for troubleshooting"
✅ "Investigated Jira MCP server integration issues, resolved authentication failures, updated environment variable configuration, and successfully tested work report generation with proper data aggregation from multiple sources"
✅ "Refactored legacy GitHub PR analysis logic to improve performance by 70%, migrating from sequential processing to parallel batch API calls with proper error handling and retry mechanisms"
Guidelines:
Word Count Examples:
20 words (minimum): "Implemented user authentication system for React dashboard using JWT tokens, OAuth2 integration, role-based access control, and comprehensive security audit logging"
25 words (sweet spot): "Developed automated CI/CD pipeline for Kubernetes deployments including container builds, security scanning, integration tests, staging validation, and production rollout with zero-downtime blue-green deployment strategy"
30 words (maximum): "Created end-to-end monitoring solution for distributed microservices architecture integrating Prometheus metrics collection, Grafana dashboards, AlertManager notifications, distributed tracing with Jaeger, and custom SLO tracking for critical business workflows"
Show the summary and suggest the name:
## 📊 Session Summary Generated
[Display the full summary here]
---
## 💾 Suggested Session Name
**Proposed (25 words):**
`[Generated detailed name with 20-30 words]`
**Word count:** [X] words
**Current:** `[Current session name if available]`
Would you like me to:
1. ✅ Apply this name to the session
2. ✏️ Generate alternative names
3. 🔄 Adjust word count (make shorter/longer)
4. ❌ Keep current name
IMPORTANT: This skill uses a hybrid approach for maximum compatibility with ccsm (Claude Code Session Manager):
.jsonl file for fast title lookup~/.claude/summaries/ for detailed viewAppend a metadata entry to the current session's JSONL file:
# Find current session file (most recently modified JSONL in projects)
SESSION_FILE=$(find ~/.claude/projects -name "*.jsonl" -type f | xargs ls -t | head -1)
# Extract session ID from filename
SESSION_ID=$(basename "$SESSION_FILE" .jsonl)
# Prepare metadata entry
METADATA_ENTRY=$(cat <<EOF
{"type":"metadata","sessionId":"${SESSION_ID}","timestamp":"$(date -u +%Y-%m-%dT%H:%M:%SZ)","summary":{"title":"${GENERATED_TITLE}","topics":${TOPICS_JSON},"wordCount":${WORD_COUNT}}}
EOF
)
# Append to session file
echo "$METADATA_ENTRY" >> "$SESSION_FILE"
Field Specifications:
type: Always "metadata" (distinguishes from user/assistant messages)sessionId: Extract from filename (UUID format)timestamp: ISO 8601 format in UTCsummary.title: The 20-30 word generated session namesummary.topics: JSON array of topic strings (e.g., ["claude-code", "git-workflow"])summary.wordCount: Integer count for validationExample metadata entry:
{
"type": "metadata",
"sessionId": "abc123-def456-ghi789",
"timestamp": "2026-03-03T09:30:45Z",
"summary": {
"title": "Created session-summary skill for Claude Code enabling automated conversation analysis and intelligent 20-30 word descriptive naming with comprehensive documentation",
"topics": ["claude-code", "skill-development", "session-management"],
"wordCount": 27
}
}
Create comprehensive summary file in ~/.claude/summaries/:
# Create summaries directory
mkdir -p ~/.claude/summaries
# Prepare full summary JSON
SUMMARY_FILE=~/.claude/summaries/${SESSION_ID}.json
cat > "$SUMMARY_FILE" <<EOF
{
"sessionId": "${SESSION_ID}",
"generatedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"title": "${GENERATED_TITLE}",
"wordCount": ${WORD_COUNT},
"overview": "${OVERVIEW_PARAGRAPH}",
"topics": ${TOPICS_JSON},
"accomplishments": ${ACCOMPLISHMENTS_JSON},
"filesChanged": {
"created": ${FILES_CREATED_JSON},
"modified": ${FILES_MODIFIED_JSON},
"deleted": ${FILES_DELETED_JSON}
},
"toolsUsed": ${TOOLS_JSON},
"keyDecisions": ${DECISIONS_JSON},
"remainingWork": ${REMAINING_WORK_JSON},
"tags": ${TAGS_JSON},
"metrics": {
"duration": "${DURATION}",
"messageCount": ${MESSAGE_COUNT},
"commandsExecuted": ${COMMANDS_COUNT}
}
}
EOF
Full Summary Schema:
{
"sessionId": "string (UUID)",
"generatedAt": "string (ISO 8601)",
"title": "string (20-30 words)",
"wordCount": "number",
"overview": "string (paragraph)",
"topics": ["string"],
"accomplishments": ["string"],
"filesChanged": {
"created": ["string"],
"modified": ["string"],
"deleted": ["string"]
},
"toolsUsed": [{"name": "string", "purpose": "string"}],
"keyDecisions": [{"decision": "string", "rationale": "string"}],
"remainingWork": ["string"],
"tags": ["string"],
"metrics": {
"duration": "string",
"messageCount": "number",
"commandsExecuted": "number"
}
}
After writing both metadata and full summary:
echo "✅ Session summary persisted successfully!"
echo ""
echo "📝 Metadata appended to: $SESSION_FILE"
echo "📊 Full summary written to: $SUMMARY_FILE"
echo ""
echo "Integration with ccsm:"
echo " • 'ccsm list' will show AI-generated title"
echo " • 'ccsm show ${SESSION_ID}' will display full summary"
To implement rename functionality, we need to understand the session storage format:
# Check common locations
ls -la ~/.claude/sessions/
ls -la ~/.config/claude/sessions/
ls -la ~/.local/share/claude/sessions/
# Find all potential session files
find ~ -path "*/claude/sessions/*" -type f 2>/dev/null
# Read a session file to understand format
cat "$(find ~/.claude/sessions -type f | head -1)" | head -50
# Or if they're JSON:
jq '.' "$(find ~/.claude/sessions -type f -name "*.json" | head -1)" | head -50
# Or if they're JSONL:
head -20 "$(find ~/.claude/sessions -type f -name "*.jsonl" | head -1)"
Look for fields like:
titlenamesessionNamedisplayNamemetadata.titleOnce the format is known, update the appropriate field:
// Example for JSON format
const sessionFile = "/path/to/session.json";
const sessionData = JSON.parse(fs.readFileSync(sessionFile, 'utf8'));
sessionData.title = "New detailed session name with 20-30 words describing the work";
fs.writeFileSync(sessionFile, JSON.stringify(sessionData, null, 2));
function generateSessionName(summary) {
// Extract key components
const mainAction = extractPrimaryAction(summary.accomplishments);
const technologies = extractTechnologies(summary);
const context = extractContext(summary);
const outcomes = extractOutcomes(summary);
const details = extractKeyDetails(summary);
// Build descriptive name
let name = `${mainAction} `;
// Add primary technology/domain
if (technologies.length > 0) {
name += `${technologies[0]} `;
}
// Add context and purpose
if (context) {
name += `${context} `;
}
// Add implementation details
if (details.length > 0) {
name += `including ${details.join(', ')} `;
}
// Add outcomes/improvements
if (outcomes.length > 0) {
name += `${outcomes.join(', ')} `;
}
// Ensure 20-30 word range
const wordCount = name.trim().split(/\s+/).length;
if (wordCount < 20) {
// Add more details
name = expandWithMoreContext(name, summary);
} else if (wordCount > 30) {
// Trim less important details
name = trimToEssentials(name, 30);
}
return {
name: name.trim(),
wordCount: name.trim().split(/\s+/).length
};
}
Priority 1 (Always include):
Priority 2 (Usually include):
Priority 3 (Include if space allows):
Feature Development (25 words): "Implemented comprehensive user authentication system for React SPA including JWT token management, OAuth2 social login, role-based authorization, session persistence, and security best practices"
Bug Fix (23 words): "Resolved critical memory leak in Node.js WebSocket server affecting production stability by implementing proper event listener cleanup, connection pooling, and comprehensive monitoring"
Refactoring (27 words): "Refactored monolithic Express application into microservices architecture using Docker containers, Kubernetes orchestration, service mesh communication, centralized logging, distributed tracing, and automated deployment pipelines"
Investigation (24 words): "Investigated intermittent database connection timeout issues in production environment, analyzed slow query logs, identified N+1 query patterns, and documented optimization recommendations"
Documentation (22 words): "Created comprehensive API documentation for RESTful endpoints using OpenAPI specification, including request/response examples, authentication flows, error codes, and integration guides"
Skill Development (26 words): "Developed automated session summary skill for Claude Code enabling intelligent conversation analysis, structured summary generation, descriptive naming with 20-30 words, and comprehensive documentation"
Handle common failure cases:
try {
// Attempt to locate session
const sessionFiles = findSessionFiles();
if (sessionFiles.length === 0) {
throw new Error("No session files found");
}
// Analyze conversation
const summary = analyzeConversation();
if (summary.topics.length === 0) {
return "⚠️ Session is too short to generate meaningful summary";
}
// Generate name with word count validation
const sessionName = generateSessionName(summary);
if (sessionName.wordCount < 20) {
console.warn(`Generated name only has ${sessionName.wordCount} words, expanding...`);
sessionName = expandName(sessionName, summary);
}
if (sessionName.wordCount > 30) {
console.warn(`Generated name has ${sessionName.wordCount} words, trimming...`);
sessionName = trimName(sessionName, 30);
}
// Present to user
presentSummary(summary, sessionName);
} catch (error) {
return `❌ Session summary failed: ${error.message}
**Possible causes:**
- Session files not accessible
- Insufficient conversation content
- Session format not recognized
**Workaround:**
You can still manually review the conversation and choose a session name.`;
}
User: "summarize this session"
→ Analyze: Feature development work
→ Generate (24 words): "Implemented complete Express API authentication middleware with passport integration, JWT tokens, refresh token rotation, rate limiting, and comprehensive security testing suite"
→ Output: Full summary + detailed name
User: "summarize what we did"
→ Analyze: Bug investigation and fix
→ Generate (26 words): "Debugged and resolved critical OVN controller memory leak affecting Kubernetes networking performance by implementing proper resource cleanup, adding memory profiling, and creating regression tests"
→ Output: Summary with debugging steps
User: "what did we accomplish?"
→ Analyze: Multiple activities
→ Generate (28 words): "Fixed authentication bugs in user login flow, implemented new dashboard features with real-time updates, and optimized database queries reducing average response time by 60 percent"
→ Output: Summary grouped by topic
✅ Good times to summarize:
❌ Avoid summarizing when:
✅ Good session names (20-30 words):
❌ Poor session names:
Always validate word count:
function validateWordCount(name) {
const words = name.trim().split(/\s+/);
const count = words.length;
if (count < 20) {
return {
valid: false,
message: `Name too short (${count} words). Need ${20 - count} more words.`,
suggestion: "Add more context about technologies, approach, or outcomes"
};
}
if (count > 30) {
return {
valid: false,
message: `Name too long (${count} words). Remove ${count - 30} words.`,
suggestion: "Focus on most important details, remove redundant phrases"
};
}
return {
valid: true,
count: count,
message: `Perfect length (${count} words)`
};
}
Cause: Session too simple or too complex
Solution for simple sessions:
Expand with:
- Technologies used (even common ones)
- Methodology/approach taken
- Quality attributes (performance, security, maintainability)
- Context and environment details
Solution for complex sessions:
Focus on:
- Most significant accomplishment
- Primary technology/domain
- Key outcome or metric
- Core implementation detail
Cause: Including redundant information
Solution:
Replace redundant phrases:
❌ "Created and developed and built..."
✅ "Developed..."
❌ "For the purpose of enabling..."
✅ "Enabling..."
❌ "In order to improve..."
✅ "Improving..."
Cause: Natural language constraints
Solution:
Use efficient phrasing:
❌ "Made improvements to the performance" (5 words)
✅ "Improved performance" (2 words)
❌ "In the context of the production environment" (7 words)
✅ "In production" (2 words)
❌ "With the ability to automatically" (5 words)
✅ "Automatically" (1 word)
When implementing this skill:
Analysis Phase:
Generation Phase:
Persistence Phase (Hybrid Approach):
Presentation Phase:
Testing:
User: "summarize this session and rename it"
## 📊 Session Summary
### 📋 Overview
Created a comprehensive Claude Code skill for automated session summarization
and intelligent renaming. Developed complete implementation including conversation
analysis, structured summary generation, and descriptive 20-30 word naming
convention with validation and examples.
### 🎯 Key Topics
- Claude Code session management and automation
- Skill development patterns and best practices
- Session storage format investigation
- Descriptive naming conventions (20-30 words)
- Name generation algorithms and validation
### ✅ Accomplishments
1. Created new git branch: feature/session-summary-rename-skill
2. Developed comprehensive SKILL.md with detailed implementation guide
3. Defined session analysis workflow and naming algorithm
4. Created 20-30 word naming convention with validation logic
5. Documented complete examples across different session types
6. Established best practices and troubleshooting guides
### 📝 Files Changed
Created:
- skills/session-summary/SKILL.md (comprehensive documentation)
### 🔧 Skills & Tools Used
- Git: Branch creation and version control
- Glob: Analyzed existing skill patterns
- Read: Examined skill structure examples
- Write: Created new skill documentation
### 💡 Key Decisions
- Use 20-30 word descriptive names (not brief titles)
- Include technologies, approach, and outcomes in names
- Validate word count programmatically
- Provide expansion/trimming strategies
- Front-load important information
### 🏷️ Suggested Tags
claude-code, skill-development, session-management, automation, naming-conventions
---
## 💾 Suggested Session Name
**Proposed (27 words):**
`Developed comprehensive session-summary skill for Claude Code enabling automated conversation analysis, structured summary generation, and intelligent 20-30 word descriptive naming with validation, examples, and implementation documentation`
**Word count:** 27 words ✅
Would you like me to apply this name to the session?
[Action] + [Technology/Domain] + [Key Details] + [Outcomes]
= 20-30 words
This skill integrates seamlessly with ccsm (Claude Code Session Manager) for enhanced session discovery and management.
Before Integration:
$ ccsm list
📅 Today (Mar 3)
────────────────────────────────────
abc123 02:15 how can I see the skill in claude?
project: my-claude-skills branch: main msgs: 45
After Integration:
$ ccsm list
📅 Today (Mar 3)
────────────────────────────────────
abc123 02:15 Created session-summary skill for Claude Code enabling...
project: my-claude-skills branch: main msgs: 45
topics: claude-code, skill-development, session-management
New Command - Full Summary:
$ ccsm show abc123
📊 Session Summary
📋 Overview:
Developed and deployed comprehensive session-summary skill for Claude Code
enabling automated conversation analysis and intelligent 20-30 word session
naming...
🎯 Key Topics:
• Claude Code session management
• Skill development workflow
• 20-30 word naming convention
✅ Accomplishments:
1. Created feature branch feature/session-summary-rename-skill
2. Developed comprehensive SKILL.md with detailed implementation guide
...
📝 Files Changed:
Created:
• skills/session-summary/SKILL.md (689 lines)
• skills/session-summary/README.md (93 lines)
🔧 Tools Used:
• Git - Branch creation and version control
• Write - Created comprehensive skill documentation
📈 Metrics:
• Duration: Full development session
• Messages: 45
• Commands: 12+
1. Install ccsm with summary support:
# ccsm v0.2.0+ includes summary metadata parsing
go install github.com/kewang/ccsm/cmd/ccsm@latest
2. Use session-summary skill:
# At end of work session
/session-summary
# Or ask Claude
"summarize this session"
3. View in ccsm:
# List with AI-generated titles
ccsm list
# View full summary
ccsm show <session-id>
┌─────────────────────┐
│ Claude Code │
│ Session │
└──────┬──────────────┘
│
│ User invokes
│ /session-summary
▼
┌─────────────────────┐
│ session-summary │
│ skill analyzes │
│ conversation │
└──────┬──────────────┘
│
├─────────────────────┐
│ │
▼ ▼
┌──────────────┐ ┌─────────────────┐
│ Append to │ │ Write full │
│ .jsonl │ │ summary to │
│ (metadata) │ │ ~/.claude/ │
│ │ │ summaries/ │
└──────┬───────┘ └────────┬────────┘
│ │
│ ┌────────────────┘
│ │
▼ ▼
┌─────────────────────┐
│ ccsm reads │
│ both sources │
└──────┬──────────────┘
│
├─────────────────┐
│ │
▼ ▼
┌──────────┐ ┌──────────┐
│ ccsm │ │ ccsm │
│ list │ │ show │
│ (fast) │ │ (detail) │
└──────────┘ └──────────┘
~/.claude/
├── projects/
│ └── <project-dir>/
│ └── <session-id>.jsonl # ← Metadata appended here
└── summaries/
└── <session-id>.json # ← Full summary written here
✅ Better Discovery: Find sessions by meaningful descriptions, not first messages ✅ Rich Context: View full summaries without opening Claude Code ✅ Fast Search: ccsm can search across AI-generated topics and titles ✅ No Duplication: Hybrid approach balances speed and detail ✅ Backward Compatible: Works with old sessions that lack metadata
name.trim().split(/\s+/).lengthnpx claudepluginhub wangke19/my-claude-skills --plugin cc-aidCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.