scratch-workspace
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScratch Workspace Management
临时工作区管理
This skill covers proper use of the directory for temporary, exploratory, and draft work.
.claude/.scratch/本技能介绍了如何正确使用目录来存放临时、探索性和草稿类工作内容。
.claude/.scratch/Purpose
用途
The scratch workspace provides a gitignored location for:
- Draft implementations
- Experimental code
- Temporary test files
- Planning documents
- Any work-in-progress that shouldn't be committed
临时工作区提供了一个被git忽略的存储位置,用于存放:
- 草稿实现代码
- 实验性代码
- 临时测试文件
- 规划文档
- 任何不应提交的在研工作内容
Setup Checklist
设置检查清单
Before creating scratch files:
-
Ensure directory existsbash
mkdir -p .claude/.scratch -
Verify gitignoreCheckcontains:
.gitignore.claude/.scratchIf missing, add it:bashecho '.claude/.scratch' >> .gitignore
创建临时文件前:
-
确保目录存在bash
mkdir -p .claude/.scratch -
验证gitignore配置检查文件中是否包含:
.gitignore.claude/.scratch如果缺失,添加该配置:bashecho '.claude/.scratch' >> .gitignore
Directory Structure
目录结构
Organize scratch files by purpose:
.claude/
├── .scratch/
│ ├── drafts/ # Work-in-progress implementations
│ │ └── feature-x.ts
│ ├── experiments/ # Exploratory code
│ │ └── perf-test.js
│ ├── notes/ # Planning and notes
│ │ └── architecture.md
│ └── temp/ # Truly temporary files
└── settings.json # Claude settings (NOT scratch)按用途组织临时文件:
.claude/
├── .scratch/
│ ├── drafts/ # 待完善的实现代码
│ │ └── feature-x.ts
│ ├── experiments/ # 探索性代码
│ │ └── perf-test.js
│ ├── notes/ # 规划与笔记
│ │ └── architecture.md
│ └── temp/ # 纯临时文件
└── settings.json # Claude配置文件(不属于临时内容)Best Practices
最佳实践
DO
建议做法
- Create subdirectories for organization
- Use descriptive file names
- Clean up when work is complete
- Move finalized code to proper project locations
- 创建子目录进行分类管理
- 使用具有描述性的文件名
- 工作完成后及时清理
- 将定稿代码迁移到项目的正式目录
DON'T
禁止做法
- Put sensitive data in scratch (still on disk)
- Use scratch for files that should be committed
- Leave stale scratch files indefinitely
- Put scratch files outside
.claude/.scratch/
- 在临时目录中存放敏感数据(仍会存储在磁盘上)
- 用临时目录存放应提交的文件
- 长期保留过时的临时文件
- 将临时文件存放在目录之外
.claude/.scratch/
Workflow
工作流程
Starting Exploratory Work
开始探索性工作
bash
undefinedbash
undefinedCreate scratch area
创建临时工作区
mkdir -p .claude/.scratch/experiments
mkdir -p .claude/.scratch/experiments
Work on experiment
进行实验工作
... create files in .claude/.scratch/experiments/
... 在.claude/.scratch/experiments/目录下创建文件
undefinedundefinedPromoting to Real Code
迁移为正式代码
When scratch work is ready:
- Review and refine the code
- Move to appropriate project location
- Delete scratch version
- Commit the promoted code
当临时工作内容准备就绪时:
- 审阅并优化代码
- 迁移到项目的对应正式目录
- 删除临时版本
- 提交迁移后的正式代码
Cleanup
清理工作
Periodically clean scratch:
bash
undefined定期清理临时工作区:
bash
undefinedReview what's in scratch
查看临时工作区内容
ls -la .claude/.scratch/
ls -la .claude/.scratch/
Remove old experiments
删除旧的实验内容
rm -rf .claude/.scratch/experiments/old-test/
undefinedrm -rf .claude/.scratch/experiments/old-test/
undefinedIntegration with Other Tools
与其他工具的集成
With Git
与Git集成
The directory is gitignored, so:
.claude/.scratch- won't show scratch files
git status - won't stage scratch files
git add . - Scratch files won't appear in commits
.claude/.scratch- 不会显示临时文件
git status - 不会暂存临时文件
git add . - 临时文件不会出现在提交记录中
With IDE
与IDE集成
Most IDEs will show in the file tree. You can:
.claude/.scratch- Add to IDE's exclude patterns
- Keep visible for easy access
- Use IDE's "mark as excluded" feature
大多数IDE会在文件树中显示目录,你可以:
.claude/.scratch- 将其添加到IDE的排除模式中
- 保持可见以便快速访问
- 使用IDE的“标记为排除”功能
Common Patterns
常见使用模式
Draft Implementation
草稿实现
.claude/.scratch/drafts/
└── new-feature/
├── index.ts
├── types.ts
└── test.ts.claude/.scratch/drafts/
└── new-feature/
├── index.ts
├── types.ts
└── test.tsPerformance Experiment
性能实验
.claude/.scratch/experiments/
└── perf-comparison/
├── approach-a.ts
├── approach-b.ts
└── benchmark.ts.claude/.scratch/experiments/
└── perf-comparison/
├── approach-a.ts
├── approach-b.ts
└── benchmark.tsArchitecture Notes
架构笔记
.claude/.scratch/notes/
└── refactor-plan.md.claude/.scratch/notes/
└── refactor-plan.mdTroubleshooting
故障排除
Scratch files appearing in git status
临时文件出现在git status中
bash
undefinedbash
undefinedVerify gitignore entry
验证gitignore中的配置条目
grep -r ".claude/.scratch" .gitignore
grep -r ".claude/.scratch" .gitignore
If missing, add it
如果缺失,添加该配置
echo '.claude/.scratch' >> .gitignore
undefinedecho '.claude/.scratch' >> .gitignore
undefinedDirectory doesn't exist
目录不存在
bash
mkdir -p .claude/.scratchbash
mkdir -p .claude/.scratchAccidentally committed scratch files
意外提交了临时文件
bash
undefinedbash
undefinedRemove from tracking but keep locally
从版本跟踪中移除但保留本地文件
git rm -r --cached .claude/.scratch
git commit -m "chore: remove scratch files from tracking"
undefinedgit rm -r --cached .claude/.scratch
git commit -m "chore: remove scratch files from tracking"
undefined