Claude Code 使用技巧 —— 历史提示词查询
·
Claude Code 使用技巧 —— 历史提示词查询
你发现Claude Code里没有/history命令,这个情况很常见——不同版本的Claude Code内置命令会有差异,尤其是早期版本确实没有这个快捷命令。别担心,我会给你适配的、能精准查看历史提示词的替代方案。希望后续版本支持history功能。
直接查看本地会话文件(最可靠,所有版本通用)
不管哪个版本的Claude Code,都会把会话内容以JSONL格式保存在本地,这是查看历史提示词的核心方式。
操作方法
# 1.进入claude会话文件夹 (复制到终端执行)
# Mac/Linux
cd ~/.claude/projects/
# windows
# git bash
cd c:; cd /Users/username/.claude/projects/
# powershell 直接就在用户目录,直接输入下面命令即可
cd .claude\projects
# 2.进入到指定项目文件夹
# Mac/Linux/git bash
# 先ls -l 查看有哪些项目
$ ls -l
total 32
drwxr-xr-x 1 Administrator 197121 0 Jan 25 00:32 project1
drwxr-xr-x 1 Administrator 197121 0 Jan 11 06:22 project2
# 以project2 为例
cd project2
# 3.查看会话历史文件,一般是大小最大的文件,并且还有对应的目录
ls -l
-rw-r--r-- 1 Administrator 197121 21K Jan 24 09:01 4dde9aa4-fd65-4023-aa3a-724e65418963.jsonl
-rw-r--r-- 1 Administrator 197121 559 Jan 24 05:49 6e6cd7a7-ea8f-4418-b574-f47bf49349a7.jsonl
drwxr-xr-x 1 Administrator 197121 0 Jan 24 06:40 7ba1d1d7-063a-4591-b323-42b6dd78d9b0/
-rw-r--r-- 1 Administrator 197121 12M Jan 25 00:21 7ba1d1d7-063a-4591-b323-42b6dd78d9b0.jsonl
-rw-r--r-- 1 Administrator 197121 4.6K Jan 24 06:31 9f3f2402-7c6e-4e16-bcb0-a46f68247604.jsonl
-rw-r--r-- 1 Administrator 197121 16K Jan 24 23:12 c54e5bba-cbb0-4d10-aa44-456e0d5d0b0d.jsonl
-rw-r--r-- 1 Administrator 197121 12K Jan 24 09:34 c5c665f1-4720-4a95-a492-617b0fc3968d.jsonl
-rw-r--r-- 1 Administrator 197121 3.8K Jan 24 06:57 e611df83-3e3a-46c4-8553-ae92be2b58fd.jsonl
# 可以看到7ba1d1d7-063a-4591-b323-42b6dd78d9b0.jsonl最大并且有对应的路径,那么这个文件就是我们要找到会话历史文件
# 4.过滤用户提示词命令
grep '"role":"user","content":\[{"type":"text","text":"' 7ba1d1d7-063a-4591-b323-42b6dd78d9b0.jsonl | grep -v '"text":"<\|"text":"\[' > user.txt
# 可以看到user.txt大小小很多(12MB --> 30KB),
# 主要都是你的提示词内容,你可以提取你认为不错的提示词另外保存,以备不时之需。
ls -lh user.txt
-rw-r--r-- 1 Administrator 197121 30K Jan 25 00:38 user.txt
历史的提示词
这是我的一个项目的历史提示词,只有个别不是提示词,前台都是我之前的问过的提示词
{"parentUuid":null,"isSidechain":false,"userType":"external","cwd":"h:\\github\\Idle Legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","type":"user","message":{"role":"user","content":[{"type":"text","text":"进入当前工程路径"}]},"uuid":"f6e5d432-9201-4705-8077-058ac7f585f2","timestamp":"2026-01-23T21:44:34.071Z"}
{"parentUuid":"983382ab-df48-40e0-abb4-57f665606f9f","isSidechain":false,"userType":"external","cwd":"h:\\github\\Idle Legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","type":"user","message":{"role":"user","content":[{"type":"text","text":"Please analyze this codebase and create a CLAUDE.md file, which will be given to future instances of Claude Code to operate in this repository.\n\nWhat to add:\n1. Commands that will be commonly used, such as how to build, lint, and run tests. Include the necessary commands to develop in this codebase, such as how to run a single test.\n2. High-level code architecture and structure so that future instances can be productive more quickly. Focus on the \"big picture\" architecture that requires reading multiple files to understand.\n\nUsage notes:\n- If there's already a CLAUDE.md, suggest improvements to it.\n- When you make the initial CLAUDE.md, do not repeat yourself and do not include obvious instructions like \"Provide helpful error messages to users\", \"Write unit tests for all new utilities\", \"Never include sensitive information (API keys, tokens) in code or commits\".\n- Avoid listing every component or file structure that can be easily discovered.\n- Don't include generic development practices.\n- If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include the important parts.\n- If there is a README.md, make sure to include the important parts.\n- Do not make up information such as \"Common Development Tasks\", \"Tips for Development\", \"Support and Documentation\" unless this is expressly included in other files that you read.\n- Be sure to prefix the file with the following text:\n\n```\n# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n```"}]},"isMeta":true,"uuid":"099948e1-a91f-4c47-a9fa-27e032eaecd0","timestamp":"2026-01-23T21:44:51.571Z"}
{"parentUuid":"e86e3f2d-9f03-456a-88f3-12232a7afa4e","isSidechain":false,"userType":"external","cwd":"h:\\github\\Idle Legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"文档换成中文描述的"}]},"uuid":"f43aa72e-095b-492b-a999-21594d3ca54d","timestamp":"2026-01-23T21:49:35.840Z"}
{"parentUuid":"68bf8d5b-b57d-4030-9e5c-481d737ee24e","isSidechain":false,"userType":"external","cwd":"h:\\github\\Idle Legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"[Request interrupted by user for tool use]"}]},"uuid":"1b0d77ea-fcb7-4da5-b4be-bd4d97f970d3","timestamp":"2026-01-23T21:50:39.074Z"}
{"parentUuid":"10362faa-cf3a-4121-a074-c9411c78d265","isSidechain":false,"userType":"external","cwd":"h:\\github\\Idle Legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"分析项目全部代码,生成一份整体架构设计文档,然后再基于各个模块,生成相关模块的详细设计文档"}]},"uuid":"8da5b6e9-b50c-4ddb-8e1f-1245838e51db","timestamp":"2026-01-23T22:02:23.316Z"}
{"parentUuid":"7de443c8-d5f4-46e4-9705-afded047586a","isSidechain":false,"userType":"external","cwd":"h:\\github\\Idle Legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"将Idle Legend重命名为idle-legend"}]},"uuid":"e155d468-8872-4914-a930-968937e9f6f7","timestamp":"2026-01-23T22:28:26.400Z","todos":[]}
{"parentUuid":"c85cf401-ff46-48a5-b731-5b32903a8b1e","isSidechain":false,"userType":"external","cwd":"h:\\github\\Idle Legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"[Request interrupted by user for tool use]"}]},"uuid":"21e8ba94-511f-4b44-8fc4-deb5252ae89a","timestamp":"2026-01-23T22:28:41.400Z"}
{"parentUuid":"cd811a22-943d-436e-b325-13abaae8aca7","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"重新write"}]},"uuid":"75a46d66-97e4-4f81-b05c-3e90f1f68e70","timestamp":"2026-01-23T21:50:55.498Z"}
{"parentUuid":"14e4c4ef-a015-4984-baaa-f146a0dbb750","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"后面回答和文档编写等都用中文,除非特殊知名用英文"}]},"uuid":"53a43301-ee13-4505-970b-d6f6fcbb1703","timestamp":"2026-01-23T21:52:16.331Z"}
{"parentUuid":"b66223ed-f5d1-40ad-a63e-393cda706481","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"请加载.claude目录配置,我已经配置了一个agents"}]},"uuid":"d6f59b50-cf12-436d-a863-9e5e928f599d","timestamp":"2026-01-23T22:00:40.465Z"}
{"parentUuid":"25fcfa04-ff1a-4fb6-a103-a2e9439f156d","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"分析项目全部代码,生成一份整体架构设计文档,然后再基于各个模块,生成相关模块的详细设计文档"}]},"uuid":"1d34144a-0509-4d2d-9204-b0481123a640","timestamp":"2026-01-23T22:02:23.316Z"}
{"parentUuid":"4696b7da-eab1-49b6-bef9-7318b3adda01","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"将Idle Legend重命名为idle-legend"}]},"uuid":"573c4e21-7cbd-45e2-9e42-b96b205e37a5","timestamp":"2026-01-23T22:28:26.400Z"}
{"parentUuid":"c6191080-21df-424c-87bb-0b2a39b08e5e","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"[Request interrupted by user for tool use]"}]},"uuid":"8ff40e1b-d520-496f-8f08-c8eedf14f937","timestamp":"2026-01-23T22:28:41.400Z"}
{"parentUuid":"a40041e3-56e3-4169-bca4-77ad611ef96d","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"master","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"[Request interrupted by user for tool use]"}]},"uuid":"85d31908-b955-43a0-8353-9d0d0dde213c","timestamp":"2026-01-23T22:42:00.575Z"}
{"parentUuid":"85d31908-b955-43a0-8353-9d0d0dde213c","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"master","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"不要自己主动push"}]},"uuid":"69bee44b-99eb-483e-b51f-775207cc3511","timestamp":"2026-01-23T22:42:25.543Z"}
{"parentUuid":"08728c0d-a6ba-496d-b61d-00999e388c0c","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"dev","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"请和github git@github.com:JYang1986/idle-legend.git 关联上"}]},"uuid":"cbb924c2-d7a2-4d4e-b827-d7af55f8f1c9","timestamp":"2026-01-23T22:38:59.838Z"}
{"parentUuid":"04b5624b-ea1a-4ffe-b94b-3a09f7ce95cc","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"dev","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"[Request interrupted by user for tool use]"}]},"uuid":"2431c069-4537-4fe0-b864-6974493baa2b","timestamp":"2026-01-23T22:42:00.575Z"}
{"parentUuid":"2431c069-4537-4fe0-b864-6974493baa2b","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"dev","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"不要自己主动push"}]},"uuid":"33a27216-811b-42f3-a797-0aa91a728156","timestamp":"2026-01-23T22:42:25.543Z"}
{"parentUuid":"87d4a744-0e56-48a8-ad6b-6b2da48a1228","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"dev","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"提交一个commit"}]},"uuid":"c9f34c86-798d-4fa1-92fe-9a6d65b1bf06","timestamp":"2026-01-23T23:17:58.205Z"}
{"parentUuid":"ee17a988-cfc1-456c-8196-9c41d4096d5f","isSidechain":false,"userType":"external","cwd":"h:\\github\\idle-legend","sessionId":"7ba1d1d7-063a-4591-b323-42b6dd78d9b0","version":"2.1.7","gitBranch":"dev","slug":"resilient-watching-blanket","type":"user","message":{"role":"user","content":[{"type":"text","text":"回退这次提交,描述的要准确些,提交都用英文,请重新提交"}]},"uuid":"8d74576f-73cb-430a-bb75-3fb6e1f5ede6","timestamp":"2026-01-23T23:19:20.897Z"}
.....
精炼的提示词
这是我觉得不错的用于保存的提示词,当作的提示词库,用来以后借鉴和参考。
1.分析项目全部代码,生成一份整体架构设计文档,然后再基于各个模块,生成相关模块的详细设计文档
2.将这次提交的要求记录到相关文件当中,以便以后不再犯类似错误
3.先帮我配置一些常用的agent,还有现有的agent有什么需要修改
4.请问如何安排sub agent做事情,如果提前预设好了几个agent,你会跟据任务内容自主分配任务给agent吗?
5.请code-reviewer帮忙分析项目代码的问题,把问题汇总到文档中,然后请refactor-expert修改代码问题
6.请将代码审查后修复文档移到新的目录里面,不要和设计文档混淆
7.把这次出的问题总结以下,避免下次再出现,记录到新的文档中。
8.每次不一样的错误都记录以下,以免以后再犯。
9.后期的commit内容要精炼些,只说主要做了什么即可,不需要累出详细的修改,通过diff就可以判断。
10.将这个规则也保存下,避免忘记。
11.将编辑器预览相关的问题也记录到文档,以供后面查阅定位问题。
12.如果开发一个新功能,应该交给哪个agent做比较合理?
13.将这个使用方法也加入到文档中
希望这个方法能够帮助到你,欢迎在评论区分享你的方案。
更多推荐



所有评论(0)