working-in-scratch-areas — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited working-in-scratch-areas (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Helps Claude save one-off scripts and documents to persistent scratch areas instead of littering repositories with temporary files or using /tmp.
Core principles:
/tmp or project tmp/ directories for these files.scratch/ subdirectories with contextAnnounce at start: "I'm using the working-in-scratch-areas skill."
Use this skill when creating:
Don't use for:
NEVER use `/tmp` or project `tmp/` directories. Always use .scratch/ for temporary work.
First, check if a scratch area already exists:
test -L .scratch && echo "Scratch area exists" || echo "No scratch area"If the symlink exists, verify gitignore is configured (see below), then you're ready to use it.
When no scratch area exists:
~/.claude/CLAUDE.mdSetup Steps:
# 1. Get repo root
git rev-parse --show-toplevel
# Output: /Users/josh/workspace/some-repo
# 2. Check if configured in CLAUDE.md
grep -i "scratch areas:" ~/.claude/CLAUDE.md
# 3a. If configured, run setup (reads from CLAUDE.md automatically)
cd /Users/josh/workspace/some-repo && ~/.claude/skills/working-in-scratch-areas/scripts/setup-scratch-area.sh
# 3b. If not configured, ask user for location and run with --areas-root
cd /Users/josh/workspace/some-repo && ~/.claude/skills/working-in-scratch-areas/scripts/setup-scratch-area.sh --areas-root ~/workspace/scratch-areas
# 3c. If user wants to save preference, add --save-to-claude-md flag
cd /Users/josh/workspace/some-repo && ~/.claude/skills/working-in-scratch-areas/scripts/setup-scratch-area.sh --areas-root ~/workspace/scratch-areas --save-to-claude-md
# 4. Verify gitignore (see Gitignore Setup section below)What the script does:
~/.claude/CLAUDE.md for configured scratch areas location (or accepts --areas-root flag){repo-root}/.scratch → scratch areaScript Location: ~/.claude/skills/working-in-scratch-areas/scripts/setup-scratch-area.sh
Script Options:
--areas-root PATH - Specify scratch areas root directory (required if not in CLAUDE.md)--save-to-claude-md - Save the areas root to ~/.claude/CLAUDE.md for future use--help - Show help messageThe setup script checks ~/.claude/CLAUDE.md for your preferred scratch areas location. If not found, you must provide --areas-root flag.
To configure in CLAUDE.md, add:
## Scratch Areas
When using the `dev-tools:working-in-scratch-areas` skill, create scratch areas in `~/workspace/scratch-areas` directory.Suggested locations to offer user:
~/workspace/scratch-areas - Central location for all scratch areas~/workspace/pickled-scratch-area/areas - If using the full pickled-scratch-area repository$(dirname "$REPO_ROOT")/scratch-areas - Sibling to current repository (for project-specific scratch areas)Use AskUserQuestion to present these options when not configured.
After creating scratch area, ensure .scratch is gitignored:
Preferred: Global gitignore
# Check if globally ignored
git config --global core.excludesfile
# Verify .scratch is in that file
# If not set up, add to global gitignore
echo ".scratch" >> ~/.gitignore
git config --global core.excludesfile ~/.gitignoreAlternative: Project .gitignore
If global gitignore isn't used:
# Add to project .gitignore if not present
grep -q "^\.scratch$" .gitignore || echo ".scratch" >> .gitignoreWhy global is preferred: Prevents accidental commits across all repositories.
Organize scratch files into topic-specific subdirectories:
.scratch/
├── database-debug/
│ ├── README.md
│ ├── check-connections.sh
│ └── query-results.txt
├── performance-analysis/
│ ├── README.md
│ ├── profile-api.sh
│ └── results-2024-11-05.md
└── data-extraction/
├── README.md
└── extract-users.rbDo NOT create files directly in `.scratch/` root. Always use a subdirectory.
ls -la .scratch/.scratch/database-debug/ directory. Should I add this script there, or create a new subdirectory?"database-debug, api-performance, user-data-extractionEvery subdirectory MUST have a README.md describing:
Example subdirectory README:
# Database Connection Debugging
## Purpose
Scripts and notes for investigating database connection timeout issues reported on 2024-11-05.
## Files
- `check-connections.sh` - Monitor active connections
- `query-slow-queries.sql` - Identify slow queries
- `findings.md` - Investigation notes and conclusions
## Status
Investigation completed 2024-11-08. Issue was connection pool exhaustion.
Keeping files for reference.When creating scripts in scratch areas, follow these mandatory rules:
Every script MUST start with #!/usr/bin/env <command>:
#!/usr/bin/env bash#!/usr/bin/env python3#!/usr/bin/env ruby#!/usr/bin/env nodeWhy: Enables proper allow list management and makes scripts directly executable.
After creating a script (file with shebang), use the helper script to make it executable:
~/.claude/skills/working-in-scratch-areas/scripts/make-executable .scratch/subdir/script.shWhy:
./script.sh) instead of through interpreterNever use `chmod +x` directly - use the helper script instead.
Important: Only make script files executable (files with shebangs). Do NOT make markdown files, text files, or other non-script files executable. The helper script will reject files without shebangs.
When invoking scripts, use direct execution:
✅ CORRECT:
./.scratch/database-debug/check-connections.sh❌ WRONG:
bash .scratch/database-debug/check-connections.sh # Don't use interpreter
ruby .scratch/data-extraction/extract-users.rb # Don't use interpreterWhy: Direct execution respects shebang and allow list configurations.
When creating files in scratch areas, prefer the Write tool:
✅ CORRECT:
Use Write tool to create .scratch/subdir/script.sh with content❌ WRONG:
cat > .scratch/subdir/script.sh << 'EOF'
# content
EOFWhy: Write tool requires fewer approvals and is cleaner.
Every file MUST have a documentation header explaining its purpose:
Script header example:
#!/usr/bin/env bash
# check-database-connections.sh
#
# Purpose: Monitor database connection pool usage
# Created: 2024-11-05
# Used for: Investigating connection timeout issues in production
#
# This script helped identify that connection pool was being exhausted
# during peak traffic. Key finding: connection cleanup wasn't happening
# in error paths.Document header example:
# API Performance Analysis Report
## Purpose
Analysis of API response times after v2.3.0 deployment
## Created
2024-11-05
## Usage Context
Users reported 2-3x slower response times after deploying v2.3.0.
This analysis was conducted to identify the regression.
## Key Findings
- Response times increased by 150% on average
- Root cause: New verbose logging middleware
- Each request was writing 500KB of logs
- Resolution: Disabled verbose logging in production config
## Impact
This analysis prevented a rollback and identified a simple configuration fix.
Deployment was saved by changing one config value.When using git commands to add and commit files:
❌ NEVER do this:
git add .
git add -A
git add .scratch/✅ ALWAYS be explicit:
git add specific-file.rb
git add src/components/Button.tsx
git add docs/api.mdWhy: Prevents accidentally committing scratch work. Global gitignore is a safety net, but explicit adds are the first line of defense.
.scratch should be in .gitignore (globally preferred)When a file is no longer actively needed:
❌ DON'T: Delete the file ✅ DO: Add retrospective comments explaining:
Example retrospective header:
#!/usr/bin/env bash
# investigate-memory-leak.sh
#
# [RESOLVED - 2024-11-08]
# This script was used to investigate memory leaks in worker processes.
#
# Original purpose: Track memory usage over time to identify leak pattern
# Key finding: Memory leak was in redis-client gem v4.2, not our code
# Resolution: Updated gem to v4.3 which fixed the issue
# Verification: Memory usage stayed stable after upgrade
#
# Keeping this script for reference in case similar issues occur with
# other background workers.Why: Preserved scripts document your problem-solving process and findings for future reference.
test -L .scratchls -la .scratch/~/.claude/skills/working-in-scratch-areas/scripts/make-executable .scratch/subdir/script.sh./.scratch/subdir/script.shWhen a script's purpose is complete:
When creating any file in scratch area, verify:
.scratch/ root.scratch is in gitignore (global or project)For script files specifically:
#!/usr/bin/env <command>)bash or ruby)When completing work with a file:
#!/usr/bin/env bash
# investigate-{issue}.sh
#
# Purpose: Debug {specific issue}
# Created: {date}
# Used for: {context}
set -euo pipefail
# Investigation logic here
echo "Starting investigation..."
# Document findings in comments as you discover them#!/usr/bin/env bash
# extract-{data-type}.sh
#
# Purpose: Extract {specific data} for {reason}
# Created: {date}
# Used for: {context}
set -euo pipefail
# Extraction logic
# Output to .scratch/subdir/extracted-data.txt#!/usr/bin/env bash
# monitor-{resource}.sh
#
# Purpose: Monitor {resource} for {reason}
# Created: {date}
# Used for: {context}
set -euo pipefail
while true; do
# Monitoring logic
sleep 5
done# {Topic} Analysis Report
## Purpose
{What you're analyzing and why}
## Created
{Date}
## Usage Context
{Why this analysis was needed}
## Methodology
{How you approached the analysis}
## Findings
{What you discovered}
## Conclusions
{What this means}
## Next Steps / Impact
{What actions were taken based on this}For consistency:
./.scratch/)This skill provides the core functionality for working with scratch areas. For additional features like migration scripts and testing utilities, see the full repository:
Repository: ~/workspace/pickled-scratch-area/
Available tools:
migrate-scratch-areas.sh - Migrate existing scratch areas to new structuremigrate-to-dot-scratch.sh - Rename scratch symlinks to .scratchmigrate-all-scratch-areas.sh - Batch migration across multiple repositoriestest-setup-scenarios.sh - Comprehensive test suite for setup scriptrename-scratch-areas.sh - Legacy renaming utilitiesThese are typically one-time operations and not needed for day-to-day scratch area usage.
| Task | Command | ||
|---|---|---|---|
| Check if scratch exists | `test -L .scratch && echo "exists" \ | \ | echo "missing"` |
| Setup scratch area | Get repo root, then cd /path/to/repo && ~/.claude/skills/working-in-scratch-areas/scripts/setup-scratch-area.sh | ||
| Check gitignore | git config --global core.excludesfile or grep .scratch .gitignore | ||
| List subdirectories | ls -la .scratch/ | ||
| Create subdirectory | Use Write tool to create .scratch/subdir-name/README.md | ||
| Create script | Write tool with shebang + header | ||
| Make executable | ~/.claude/skills/working-in-scratch-areas/scripts/make-executable .scratch/subdir/script.sh | ||
| Run script | ./.scratch/subdir/script-name.sh (not bash .scratch/...) | ||
| Archive script | Add [RESOLVED] retrospective header, don't delete | ||
| Git add files | ALWAYS use explicit paths, NEVER git add . or git add -A |
/tmp or project tmp/ - always use .scratch/.scratch/ files to git~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.