Use when you want to create a project-specific nightly cleanup and maintenance routine - analyzes the project's tech stack and generates customized cleanup routines for caches, build artifacts, and domain-specific maintenance. Detects Next.js, Node.js, Python, Rust, etc. and creates appropriate cleanup targets. Do NOT use if the generic /popkit:routine nightly is sufficient - only generate custom routines for projects with unique cleanup requirements or domain-specific maintenance needs.
/plugin marketplace add jrc1883/popkit-claude/plugin install popkit@popkit-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
checklists/nightly-checklist.jsonscripts/calculate_sleep_score.pyworkflows/nightly-workflow.jsonGenerate a project-specific nightly cleanup and maintenance command based on the project's tech stack, services, and domain. The generated command extends /popkit:nightly with project-aware cleanup and maintenance.
Core principle: Detect what needs cleanup for THIS project and automate it every night.
Trigger: /popkit:nightly generate command or via /popkit:morning generate --nightly
This is a Pro tier feature. Free tier users can use the default /popkit:routine nightly command instead.
When a free tier user invokes this skill, redirect them to the default routine:
## Default Nightly Routine (Free Tier)
Custom routine generation requires PopKit Pro. However, you can still use the default nightly routine!
### Available Commands
Run the generic nightly routine:
/popkit:routine nightly
This provides:
- ✅ Git maintenance (gc, prune)
- ✅ Session state capture
- ✅ Basic cache cleanup hints
- ✅ Sleep Score calculation
### What Custom Generation Would Provide
With PopKit Pro, you'd get a project-specific routine including:
- ✨ **Stack-specific cleanup** - .next/, target/, __pycache__/
- 🔍 **Smart cache management** - Know what's safe to delete
- ⚡ **Domain-specific maintenance** - API token checks, backup verification
- 📊 **Disk space recovery** - Automated artifact cleanup
Run `/popkit:upgrade` to unlock custom routine generation.
import sys
sys.path.insert(0, "hooks/utils")
from premium_checker import check_entitlement
result = check_entitlement("pop-nightly-generator")
if not result.allowed:
# Redirect to default routine
print("## Default Nightly Routine (Free Tier)")
print("\nCustom routine generation requires PopKit Pro.")
print("You can use the default routine: `/popkit:routine nightly`")
print("\nRun `/popkit:upgrade` to unlock custom routine generation.")
return
.claude/commands/
└── [project]:nightly.md # Project-specific nightly cleanup
Before detecting tech stack, check for existing MCP server infrastructure:
# Check for MCP SDK in package.json
grep -q "@modelcontextprotocol/sdk" package.json 2>/dev/null && echo "MCP SDK: Found"
# Check for .mcp.json configuration
test -f .mcp.json && echo "MCP Config: Found"
# Check for MCP server directories
ls -d packages/*/mcp packages/*/src/mcp **/mcp-server 2>/dev/null && echo "MCP Directories: Found"
Decision Tree:
Has MCP SDK or .mcp.json?
│
├─ YES → Has nightly/cleanup MCP tools?
│ │
│ ├─ YES → Generate MCP wrapper commands
│ │ - Minimal 10-20 line wrappers
│ │ - Call mcp__server__tool directly
│ │ - Skip bash-based cleanup
│ │
│ └─ NO → Generate hybrid commands
│ - MCP for available tools
│ - Bash for cleanup operations
│
└─ NO → Generate bash-based commands (full)
- Complete tech stack detection
- Comprehensive bash scripts
MCP Nightly Tool Detection:
Look for these patterns in MCP tool names:
nightly_routine, nightly_* - Full nightly routinescleanup_*, clean_* - Cleanup operations*_maintenance - Maintenance tasksbackup_*, save_* - State preservationAnalyze project for frameworks and build systems:
# Package managers and their cache locations
ls package.json Cargo.toml pyproject.toml go.mod requirements.txt 2>/dev/null
# Framework detection (build artifact locations)
grep -l "next" package.json 2>/dev/null && echo "Next.js: .next/"
grep -l "vite" package.json 2>/dev/null && echo "Vite: dist/"
grep -l "react-scripts" package.json 2>/dev/null && echo "CRA: build/"
grep -l "webpack" package.json 2>/dev/null && echo "Webpack: dist/"
# Cache detection
test -d node_modules/.cache && echo "Node cache: node_modules/.cache/"
test -f .eslintcache && echo "ESLint cache: .eslintcache"
test -f .tsbuildinfo && echo "TS cache: .tsbuildinfo"
test -d .pytest_cache && echo "Pytest cache: .pytest_cache/"
test -d __pycache__ && echo "Python cache: __pycache__/"
test -d target && echo "Rust target: target/"
# Test/coverage artifacts
test -d coverage && echo "Coverage: coverage/"
test -d .nyc_output && echo "NYC output: .nyc_output/"
Based on detected stack, determine cleanup operations:
| Detection | Cleanup Targets |
|---|---|
| Next.js | .next/, out/ |
| Vite | dist/ |
| CRA | build/ |
| General Node | node_modules/.cache/, .eslintcache, .tsbuildinfo |
| TypeScript | *.tsbuildinfo, dist/ |
| Jest/Testing | coverage/, .jest-cache/ |
| Python | __pycache__/, .pytest_cache/, *.pyc |
| Rust | target/debug/ (not target/release) |
| Logs | *.log files older than 7 days |
| Temp Files | *.tmp, .DS_Store |
| Detection | Maintenance Task |
|---|---|
| Git repo | git gc --auto, git fetch --prune |
| Package.json | npm audit |
| Prisma | prisma generate check |
| Docker | docker system prune --filter "until=24h" |
| External APIs | Token expiry checks |
Determine command prefix from project (same as morning-generator):
# From package.json name
jq -r '.name' package.json | tr -d '@/' | cut -d'-' -f1
# From directory name
basename $(pwd)
# From existing commands
ls .claude/commands/*:*.md 2>/dev/null | head -1 | cut -d':' -f1
Create .claude/commands/[prefix]:nightly.md:
---
description: Nightly cleanup and maintenance for [Project Name] (Sleep Score 0-100)
---
# /[prefix]:nightly - [Project] Nightly Cleanup
End-of-day cleanup and maintenance for [Project Name].
## Usage
\`\`\`
/[prefix]:nightly # Full nightly report
/[prefix]:nightly quick # Compact summary
/[prefix]:nightly cleanup --auto-fix # Execute cleanup
/[prefix]:nightly git --auto-fix # Git maintenance
\`\`\`
## Cleanup Targets
| Category | Target | Size |
|----------|--------|------|
| Build Artifacts | [detected] | - |
| Caches | [detected] | - |
| Temp Files | [detected] | - |
| Old Logs | [detected] | - |
## Cleanup Commands
\`\`\`bash
# Build artifacts
rm -rf [detected paths]
# Caches
rm -rf [detected paths]
# Temp files
find . -name "*.tmp" -type f -delete
find . -name "*.log" -mtime +7 -type f -delete
\`\`\`
## Git Maintenance
\`\`\`bash
git gc --auto
git fetch --prune
git branch --merged main | grep -v "^\*\|main\|master" | xargs -r git branch -d
\`\`\`
## Security Check
\`\`\`bash
npm audit
\`\`\`
## Sleep Score
| Check | Points |
|-------|--------|
| No uncommitted changes | 30 |
| Session state saved | 20 |
| Git maintenance done | 15 |
| Security audit clean | 15 |
| Caches under limit | 10 |
| Logs rotated | 10 |
## Domain-Specific
[Based on project type]
- [ ] [API token expiry check]
- [ ] [Database backup status]
- [ ] [External service cleanup]
## Cleanup Targets
| Category | Target | Typical Size |
|----------|--------|--------------|
| Build | `.next/` | 100-500 MB |
| Build | `out/` | 50-200 MB |
| Cache | `node_modules/.cache/` | 50-200 MB |
| Cache | `.eslintcache` | < 1 MB |
| Cache | `.tsbuildinfo` | < 1 MB |
| Coverage | `coverage/` | 10-50 MB |
## Cleanup Commands
\`\`\`bash
# Build artifacts (safe to delete)
rm -rf .next/ out/
# Caches (safe to delete)
rm -rf node_modules/.cache .eslintcache .tsbuildinfo
# Coverage (safe to delete)
rm -rf coverage/
# Old logs
find . -name "*.log" -mtime +7 -type f -delete
\`\`\`
## Cleanup Targets
| Category | Target | Typical Size |
|----------|--------|--------------|
| Cache | `__pycache__/` | 10-50 MB |
| Cache | `.pytest_cache/` | 1-10 MB |
| Cache | `.mypy_cache/` | 5-20 MB |
| Build | `dist/` | varies |
| Build | `build/` | varies |
| Build | `*.egg-info/` | < 1 MB |
| Compiled | `*.pyc` | varies |
## Cleanup Commands
\`\`\`bash
# Python caches
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null
find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null
# Build artifacts
rm -rf dist/ build/ *.egg-info/
# Compiled files
find . -name "*.pyc" -type f -delete
\`\`\`
## Cleanup Targets
| Category | Target | Typical Size |
|----------|--------|--------------|
| Debug Build | `target/debug/` | 1-5 GB |
| Incremental | `target/debug/incremental/` | 500 MB-2 GB |
**Note:** Never delete `target/release/` automatically.
## Cleanup Commands
\`\`\`bash
# Debug artifacts only (preserves release builds)
rm -rf target/debug/
# Or more conservative - just incremental
rm -rf target/debug/incremental/
# Cargo clean (nuclear option)
# cargo clean
\`\`\`
## Domain-Specific Cleanup
| Target | Description | Command |
|--------|-------------|---------|
| API Cache | Cached API responses | `rm -rf .api-cache/` |
| Token Cache | OAuth token cache | Check expiry, don't delete |
| Image Cache | Processed images | `find uploads/cache -mtime +7 -delete` |
## Domain-Specific Checks
| Check | Description |
|-------|-------------|
| OAuth Tokens | Alert if expiring within 24h |
| API Rate Limits | Check remaining quota |
| Database Backup | Verify last backup < 24h |
After generating:
Nightly command generated!
Created:
.claude/commands/[prefix]:nightly.md
Detected stack:
- Framework: Next.js 14
- Database: Supabase (local)
- Cache: Redis
- Tests: Jest
Cleanup targets configured:
✓ .next/ (build artifacts)
✓ coverage/ (test coverage)
✓ node_modules/.cache/ (npm cache)
✓ .eslintcache (lint cache)
✓ Old log files (7+ days)
Maintenance configured:
✓ Git gc and prune
✓ npm audit
✓ Branch cleanup
You can now run:
/[prefix]:nightly
Would you like me to also generate/update /[prefix]:morning?
When MCP infrastructure with nightly tools is detected:
---
description: Nightly cleanup via MCP (Sleep Score 0-100)
---
# /[prefix]:nightly - [Project] Nightly Cleanup
Run the MCP-based nightly routine.
## Implementation
Run the `mcp__[server]__nightly_routine` MCP tool.
If unavailable, run individual cleanup tools:
- `mcp__[server]__cleanup_caches`
- `mcp__[server]__git_maintenance`
- `mcp__[server]__security_audit`
Display the Sleep Score and any issues.
Requires:
Enables:
After generation, customize by:
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.