Skip to content

fix(tools): use PAI_DIR env var instead of hardcoded ~/.claude paths#1040

Open
MarvinDontPanic wants to merge 2 commits intodanielmiessler:mainfrom
MarvinDontPanic:fix/tools-use-getpaidir
Open

fix(tools): use PAI_DIR env var instead of hardcoded ~/.claude paths#1040
MarvinDontPanic wants to merge 2 commits intodanielmiessler:mainfrom
MarvinDontPanic:fix/tools-use-getpaidir

Conversation

@MarvinDontPanic
Copy link
Copy Markdown

Summary

Adds process.env.PAI_DIR fallback to 15 PAI Tools that hardcode ~/.claude as the base directory. Each tool now checks PAI_DIR first, falling back to ~/.claude for backward compatibility.

Tools fixed: ActivityParser, AlgorithmPhaseReport, Banner, BannerMatrix, BannerNeofetch, BannerRetro, BuildCLAUDE, FeatureRegistry, LearningPatternSynthesis, LoadSkillConfig, NeofetchBanner, pai, RebuildPAI, SessionHarvester, SessionProgress.

Also includes the 4 hook fixes from #1039 (LastResponseCache, RatingCapture, SessionCleanup, WorkCompletionLearning) since the tools branch was built on top of that work.

Motivation

Claude Code v2.1.78+ hardened ~/.claude/ as a protected directory. Users who set PAI_DIR outside ~/.claude/ need tools to respect that variable. Currently, 15 tools ignore PAI_DIR entirely.

Related: #992, #873, #994, #1039

Special case: BuildCLAUDE.ts

BuildCLAUDE.ts reads PAI content from PAI_DIR but ALWAYS writes CLAUDE.md to ~/.claude/CLAUDE.md since Claude Code reads it from that fixed location.

Backward Compatible

Yes — all tools fall back to ~/.claude when PAI_DIR is not set.

Test plan

  • Tools work with default PAI_DIR=~/.claude
  • Tools work with custom PAI_DIR=~/pai
  • BuildCLAUDE.ts writes to ~/.claude/CLAUDE.md regardless of PAI_DIR

🤖 Generated with Claude Code

Marvin and others added 2 commits April 5, 2026 18:01
Add process.env.PAI_DIR fallback to 15 PAI Tools that hardcode
~/.claude as the base directory. Each tool now checks PAI_DIR first,
falling back to ~/.claude for backward compatibility.

This enables PAI_DIR portability — users can set PAI_DIR to install
PAI outside ~/.claude/ (e.g. to work around Claude Code v2.1.78+
sensitive directory protection).

Special case: BuildCLAUDE.ts still writes CLAUDE.md to ~/.claude/
since Claude Code reads it from that fixed location, but reads PAI
content from PAI_DIR.

Tools fixed: ActivityParser, AlgorithmPhaseReport, Banner,
BannerMatrix, BannerNeofetch, BannerRetro, BuildCLAUDE,
FeatureRegistry, LearningPatternSynthesis, LoadSkillConfig,
NeofetchBanner, pai, RebuildPAI, SessionHarvester, SessionProgress.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded join(HOME, '.claude') fallbacks with getPaiDir() from
hooks/lib/paths.ts in 4 hooks: LastResponseCache, RatingCapture,
SessionCleanup, WorkCompletionLearning.

This enables PAI_DIR portability — users can set PAI_DIR to install
PAI outside ~/.claude/ (e.g. to work around Claude Code v2.1.78+
sensitive directory protection).

Complements existing getPaiDir() usage in SecurityValidator,
SessionAutoName, RelationshipMemory, KittyEnvPersist, LoadContext.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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