Session history
Claude Code, Codex, and Grok local session history lookup: lists, timelines, full conversation details, tool calls, grep/search, token usage, API-equivalent cost, model rollups, and subscription quota. Use for Claude/Codex/Grok 작업 내역, 오늘 한 일, 뭐 했더라, history, grok session, 토큰 사용량, API 비용, 이번 달 얼마, 구독 한도. Do NOT use for Hermes Agent/Discord/Gateway conversations in ~/.hermes/state.db — use session_search instead. Do NOT use for personal reflection synthesis, automation packaging, memory updates, or searching current repo files.From its SKILL.md
npx -y skills add ai-native-engineer/astack --skill session-historyAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.9 KB, as published. Nobody here has run it
Session History
Claude Code (~/.claude/) + Codex (~/.codex/) + Grok (~/.grok/sessions/) 통합 세션 히스토리.
Hermes Agent 자체 대화(Discord/Telegram/Gateway/CLI)는 이 스크립트 대상이 아니다. Hermes 대화는 session_search 도구가 ~/.hermes/state.db를 검색한다.
토큰·비용
토큰/비용만 필요하면 스킬 루트에서 python3 scripts/token_usage.py를 실행한다.
- 기본: 최근 1일 토큰 합산 (
--days,--date,--month,--all-time,--tool) --cost: list API 단가 환산($). Grok은 로그의costUsdTicks우선. 표에 없는 실모델은 unpriced(합계 미포함)--by-model: 모델별 상위--quota: Claude OAuth / Codex wham 구독 한도 live (Grok 미지원)- 단가·모델 해석(placeholder/default/unpriced)·캐시 5m/1h 세부는
references/cost-measurement.md
python3 scripts/token_usage.py --days 7 --cost --by-model
python3 scripts/token_usage.py --month --cost --quota
사용법
네 서브커맨드: list(목록)·timeline(시간순, 데일리 노트용)·rg(세션 전문 검색)·show(대화 보기). grep도 같은 검색의 호환 alias다. 대표 호출:
SH="scripts/session_history.py" # 설치된 session-history 스킬 루트에서 실행
python3 $SH list --cwd # 현재 프로젝트 오늘 세션 (절대 경로 포함)
python3 $SH list --days 30 --summary # 메시지 없이 도구별 수와 상위 프로젝트만
python3 $SH list --tool grok --days 7 # Grok 세션만
python3 $SH rg "gcloud" --days 30 # 30일간 세션 JSONL 전문 검색 (맥락 발췌)
python3 $SH rg "error" --days 30 --limit 5 # 실패 신호가 있는 세션 5개만 보기
python3 $SH show --last --files # 가장 최근 세션의 수정 파일 목록
서브커맨드별 옵션은 다르다. 특히 --limit은 show·rg에만 있고 list엔 없다(목록 범위는 --days/--date로 조절). 긴 기간의 현황만 볼 때는 list --summary를 쓴다. --tool은 all|claude|codex|grok(기본 all). 출력 형식은 --format text|json만 받는다(compact 값 없음. 압축 출력은 timeline --compact 전용 플래그). 페이지네이션용 --offset은 없다. 그 밖의 플래그는 실행 전 python3 $SH <subcommand> -h로 확인한다.
비자명한 동작:
rg는list --search(history/prompt preview)와 달리 실제 세션 JSONL의 대화·도구 호출·도구 결과를 검색한다.list와timeline의 메시지 미리보기는 일반적인 API 키, 토큰, JWT 형태를 마스킹한다. 원문이 필요한show와rg는 마스킹하지 않는다.rg --limit N은 매칭 세션 수를 제한한다. 세션 안에서는 앞 3개 매칭만 요약하고, 전체 맥락은show <ID> --full로 본다.- 세션 ID는 prefix 매칭. 목록의 12자리를 그대로 붙여넣는 것을 권장 (UUID v7 특성상 앞 8자리는 동시 생성 세션끼리 충돌 가능).
- Grok 실제 사용자 발화는
chat_history.jsonl의<user_query>(또는 synthetic이 아닌 user 메시지)만 취한다. 시스템 주입·스킬 목록 등 synthetic user는 목록/검색 preview에서 제외한다. --files는 두 섹션을 출력한다:- 구조화된 파일 변경 — Claude
Edit/Write/MultiEdit/NotebookEdit+ Codexapply_patch/patch_apply_begin+ Groksearch_replace/write에서 경로 추출. - Bash/shell 변경 의심 —
rm/mv/cp/sed -i/tee/>등 파일 변경 패턴이 든 ClaudeBash, Codexshell, Grokrun_terminal_command호출.
- 구조화된 파일 변경 — Claude
워크플로우
- 현재 프로젝트 맥락 복원:
list --cwd→show <ID>또는show --last - 특정 작업 찾기:
rg "키워드"(7일 기본) →show <ID> - 오늘 데일리 노트:
timeline→ 출력 복사 붙여넣기 - 장기 현황:
list --days 30 --summary로 범위를 좁힌 뒤 필요한 날짜·프로젝트만list로 확인
대화 맥락 교정 대응
사용자가 “이전에 이 내용으로 대화했어”, “전에 확인했잖아”, “면밀하게 확인해봐”처럼 과거 대화 기반으로 교정하면, 바로 추측성 답을 고치지 말고 세션 검색을 먼저 수행한다. 특히 Hermes 설정/모드/게이트웨이 상태처럼 현재값과 과거 합의가 함께 중요한 질문은:
session_search또는 이 스킬의rg로 과거 발화/키워드를 찾는다.- 찾은 세션의 핵심 메시지와 현재 live config/state를 각각 확인한다.
- 답변은 “과거 대화에서 무엇을 확인했는지”와 “현재 상태가 그와 일치하는지”를 짧게 구분해 말한다.
이 패턴은 사용자의 교정 신호가 강한 경우 우선 적용한다. 단순히 현재 컨텍스트에 플래그가 안 보인다는 이유로 “확인 불가”라고 끝내면 안 된다.
데이터 소스
Claude Code
~/.claude/history.jsonl: user 메시지 인덱스 (display, timestamp(ms), sessionId, project)~/.claude/projects/{path}/{sessionId}.jsonl: 전체 대화 (user/assistant/tool_result)
Codex
~/.codex/history.jsonl: user 메시지 인덱스 (text, ts(sec), session_id)~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl: 전체 대화 (event_msg/response_item)
Grok
~/.grok/sessions/{url-encoded-cwd}/{sessionId}/summary.json: 세션 메타 (cwd, created_at, title)~/.grok/sessions/{url-encoded-cwd}/{sessionId}/chat_history.jsonl: 전체 대화 (user/assistant/tool_result + tool_calls)~/.grok/sessions/{url-encoded-cwd}/prompt_history.jsonl: cwd 단위 user prompt 인덱스 (list/timeline preview)~/.grok/sessions/{url-encoded-cwd}/{sessionId}/updates.jsonl: 토큰 집계 정본.sessionUpdate=turn_completed의usage(inputTokens/outputTokens/cachedReadTokens/reasoningTokens/costUsdTicks등)를 턴 단위로 합산한다.chat_history/summary에는 호출별 usage가 없다.~/.grok/sessions/session_search.sqlite는 Grok TUI 자체 FTS이며 이 스킬의 정본이 아니다. 목록·검색은 summary/chat_history/prompt_history를 직접 읽는다.
토큰·API 환산·쿼터 필드 매핑은 references/cost-measurement.md.
제한 환경 fallback (Restricted environment)
서브에이전트·샌드박스에서 session_history.py/claude CLI가 Bash 권한으로 막히거나, show <ID> --full이 세션 상세 대신 날짜 목록만 반환할 때:
- JSONL 직접 Read: 스크립트 대신 해당 소스 파일을 Read 도구로 직접 읽는다.
- Claude:
~/.claude/projects/<cwd-매핑-디렉토리>/<sessionId>.jsonl(cwd의/는-로 치환, 예: cwd/→-디렉토리) - Codex:
~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl - Grok:
~/.grok/sessions/<url-encoded-cwd>/<sessionId>/chat_history.jsonl
- Claude:
- ID 형식 불일치: Claude
history.jsonl의 sessionId는 uuid-v4, transcript 파일명은ses_*형식이라 직접 매칭이 안 될 수 있다. 안 맞으면 timestamp + cwd로 교차 탐색해 같은 세션을 찾는다. - 세션 파일 부재: 요청한 session_id가 로컬 transcript에 없으면, 같은 cwd의 형제 세션·회고(
~/.agents/memory/retros/)를 timestamp 기준으로 교차 참조해 맥락을 복원하고, 로컬에 파일이 없다는 한계를 명시한다.