Skip to content

feat(cli): add --latest flag to show or convert latest conversation#6

Open
yanggthomas wants to merge 1 commit intoannenpolka:mainfrom
yanggthomas:feat/latest-flag
Open

feat(cli): add --latest flag to show or convert latest conversation#6
yanggthomas wants to merge 1 commit intoannenpolka:mainfrom
yanggthomas:feat/latest-flag

Conversation

@yanggthomas
Copy link

@yanggthomas yanggthomas commented Jan 26, 2026

feat: Add --latest flag to show/convert latest conversation

Summary

Adds support for the --latest flag to quickly access the most recent conversation without TUI interaction.

Features

  • cclog --latest - Outputs {sessionId}\t{title} of the most recent conversation
  • cclog --latest -o - Converts latest conversation to markdown with auto-generated filename from title
  • cclog --latest -o output.md - Converts latest conversation to specific output file
  • Intelligent filename generation from conversation titles (supports CJK, English, special chars)
  • Automatic filename collision detection (adds _1, _2 suffixes)

Changes

  • Added --latest CLI flag handling in ParseArgs()
  • Added Latest and AutoOutput config fields
  • New functions: getLatestSessionInfo(), convertLatestToFile(), getUniqueFilename(), generateFilenameFromTitle(), sanitizeForFilename()
  • Added GetSessionID() in usecase to extract session UUID from filename
  • Fixed indentation (spaces→tabs) in multiple test files
  • Enhanced help text with new examples

Testing

  • Added comprehensive tests for all new functionality in command_test.go
  • Test coverage includes: basic --latest, auto-output, filename generation, collision handling

Examples

# Get latest conversation UUID and title
cclog --latest
# Output: a1b2c3d4-e5f6-7890-abcd-ef1234567890	Deploy microservices architecture

# Auto-convert to markdown (auto-named from title)
cclog --latest -o
# Output: Output written to: Deploy_microservices.md

# Convert to specific file
cclog --latest -o my_conversation.md

Possible usage with claude code

// note/SKILL.md
---
name: note
description: Save current conversation to markdown file
disable-model-invocation: true
allowed-tools: Bash(cclog*)
argument-hint: [filename.md]
---

Save the current Claude Code conversation to a markdown file using cclog.

Run: `cclog --latest -o $ARGUMENTS`

- If no filename given: auto-generates from conversation title
- If file exists: adds counter suffix (_1, _2, etc.) to avoid overwriting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant