How to safely sync improvements from Kai to public PAI
You have two systems:
- Kai (
${PAI_DIR}/) - Your private system with personal data, API keys, custom workflows - PAI (
~/Projects/PAI/) - Public template that must stay sanitized
When you improve Kai, you want to share those improvements with PAI without exposing private data.
PAI has built-in protection to prevent accidents:
Defines files that must NOT be overwritten with Kai content:
README.md- PAI-specific (not Kai README)PAI_CONTRACT.md- Defines PAI boundaries.claude/Hooks/lib/pai-paths.ts- PAI path resolution.claude/Hooks/self-test.ts- PAI health check.claude/.env.example- Template (no real keys)- More listed in the manifest
Checks for:
- ❌ API keys in committed files
- ❌ Personal email addresses
- ❌ References to private Kai data
- ❌ Secrets or credentials
Automatically runs validation before every commit.
Work in your private Kai system (${PAI_DIR}/):
cd ~/.claude
# Make improvements, add features, test thoroughlyAsk yourself:
- ✅ Is this useful for others?
- ✅ Does it work without my personal data?
- ✅ Is it generic enough for a template?
- ❌ Does it reference my private workflows?
- ❌ Does it contain API keys or secrets?
# Example: Copying a new skill
cp -r ${PAI_DIR}/Skills/new-skill ~/Projects/PAI/.claude/Skills/
# Example: Updating a hook
cp ${PAI_DIR}/Hooks/some-hook.ts ~/Projects/PAI/.claude/Hooks/IMPORTANT: Do NOT use cp -r ~/.claude ~/Projects/PAI/ (don't bulk copy everything)
Remove any:
- API keys (
ANTHROPIC_API_KEY=sk-...) - Personal emails (
daniel@danielmiessler.com) - Private file paths (
/Users/daniel/.claude/Skills/personal) - References to private services
Replace with placeholders:
# Before
ANTHROPIC_API_KEY=sk-ant-1234567890
# After
ANTHROPIC_API_KEY=your_anthropic_api_key_herecd ~/Projects/PAI
bun .claude/Hooks/self-test.tsExpected output:
✅ PAI_DIR Resolution: $HOME/.claude # Shows your actual resolved path
✅ Hooks Directory: Found
✅ CORE Skill: loads correctly
...
🎉 PAI is healthy! All core guarantees working.
cd ~/Projects/PAI
bun .claude/Hooks/validate-protected.tsExpected output:
✅ README.md
✅ PAI_CONTRACT.md
✅ .claude/Hooks/lib/pai-paths.ts
...
✅ All protected files validated successfully!
If validation fails:
❌ .claude/.env.example
→ Contains secret or personal email: @danielmiessler.com
Fix the issues and re-run validation.
cd ~/Projects/PAI
git status
git diffCheck:
- ✅ No API keys visible
- ✅ No personal emails
- ✅ No private file paths
- ✅ Protected files unchanged (unless intentional)
git add .
git commit -m "feat: add new skill for X"The pre-commit hook automatically runs validation. If it fails, the commit is blocked.
git push origin main# ❌ DON'T DO THIS
cp -r ${PAI_DIR}/* ~/Projects/PAI/.claude/Problem: Overwrites protected files, copies personal data
Solution: Copy specific files/directories only
# ❌ File contains
ELEVENLABS_API_KEY=a1b2c3d4e5f6Problem: Real API key committed to public repo
Solution: Always run validate-protected.ts before committing
# ❌ Copied Kai's README to PAI
cp ${PAI_DIR}/../README.md ~/Projects/PAI/README.mdProblem: PAI's README explains public template, Kai's README is private
Solution: Check .pai-protected.json before copying
# ❌ Commit immediately without testing
git add . && git commit -m "updates"Problem: Broken hooks, missing dependencies, invalid paths
Solution: Always run self-test.ts first
The pre-commit hook is NOT installed by default (to avoid interfering with other workflows).
To install:
cd ~/Projects/PAI
cp .claude/Hooks/pre-commit.template .git/Hooks/pre-commit
chmod +x .git/Hooks/pre-commitNow validation runs automatically before every commit.
To bypass (not recommended):
git commit --no-verify -m "message"See .pai-protected.json for the complete list.
Categories:
-
Core Documents
README.md- PAI-specific introductionPAI_CONTRACT.md- Defines what PAI guaranteesSECURITY.md- Public security guidance
-
PAI Infrastructure
.claude/Hooks/lib/pai-paths.ts- Path resolution library.claude/Hooks/self-test.ts- Health check system.claude/Hooks/validate-protected.ts- Protection validator.pai-protected.json- This manifest
-
Sanitized Config
.claude/.env.example- Template with placeholders.claude/settings.json- Generic settings (no personal tweaks)
-
Forbidden Patterns
- Personal email addresses
- Real API keys
- Private file paths
- Sensitive data patterns
Before every PAI commit:
# 1. Test PAI works
bun ~/Projects/PAI/.claude/Hooks/self-test.ts
# 2. Validate protected files
bun ~/Projects/PAI/.claude/Hooks/validate-protected.ts
# 3. Review changes
git diff
# 4. Commit (validation runs automatically if hook installed)
git commit -m "your message"When validation fails:
- Read the error messages
- Fix the violations (remove secrets, sanitize data)
- Re-run validation
- Commit once validation passes
Q: Can I disable the protection system?
A: Yes, but not recommended. You can skip by not installing the pre-commit hook or using --no-verify.
Q: What if I need to update a protected file? A: That's fine! The validation checks the content, not that files don't change. Just ensure the content stays PAI-appropriate.
Q: How do I add a new protected file?
A: Edit .pai-protected.json and add the file path to the appropriate category.
Q: Can I use rsync instead of manual copying? A: Use with extreme caution. Better to copy specific files to avoid accidents.
Q: What if I accidentally commit secrets? A: Immediately rotate the API keys, then force-push to remove from history (or contact GitHub support).
Complete example of adding a new skill from Kai to PAI:
# 1. Copy skill from Kai to PAI
cp -r ${PAI_DIR}/Skills/my-new-skill ~/Projects/PAI/.claude/Skills/
# 2. Sanitize the skill's SKILL.md
cd ~/Projects/PAI/.claude/Skills/my-new-skill
nano SKILL.md # Remove any personal references
# 3. Check if there's an .env or config file
# Remove any real API keys, replace with placeholders
# 4. Test PAI
cd ~/Projects/PAI
bun .claude/Hooks/self-test.ts
# 5. Validate protection
bun .claude/Hooks/validate-protected.ts
# 6. Review changes
git status
git diff
# 7. Commit
git add .claude/Skills/my-new-skill
git commit -m "feat(skills): add my-new-skill for doing X"
# 8. Push
git push origin mainRemember: PAI is public. Kai is private. The protection system helps keep them separate while allowing you to share improvements with the community.
🤖 Happy syncing!