### Install PAI with npm Source: https://github.com/mnott/pai/blob/main/README.md Use this command to install PAI globally for quick setup. ```bash npx @tekmidian/pai install ``` -------------------------------- ### Re-run PAI setup wizard with CLI Source: https://github.com/mnott/pai/blob/main/MANUAL.md Initiate the PAI setup wizard again. This is useful for reconfiguring PAI or starting with a clean slate. ```bash pai setup ``` -------------------------------- ### Manual PAI Installation Steps Source: https://github.com/mnott/pai/blob/main/README.md Follow these steps for a manual installation of PAI, including cloning the repository, installing dependencies, and building the project. ```bash git clone https://github.com/mnott/PAI cd PAI bun install bun run build ``` -------------------------------- ### Run PAI Setup and Quick Search Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Initiate the interactive setup wizard with `pai setup`. Use `pai search "query"` as a shortcut for full-text search. ```bash pai setup ``` ```bash pai search "query" ``` -------------------------------- ### Install PAI daemon as launchd service Source: https://github.com/mnott/pai/blob/main/MANUAL.md Set up the PAI daemon to run as a system service using launchd. This ensures the daemon starts automatically on login. ```bash pai daemon install ``` -------------------------------- ### Obsidian Vault Layout Example Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Shows the directory structure and symlink setup for the PAI Obsidian vault, linking project notes into a centralized Obsidian workspace. ```text ~/.pai/obsidian-vault/ ├── _index.md # Auto-generated landing page ├── topics/ │ ├── active-projects.md # Links to all active project folders │ └── recent-sessions.md # Latest sessions across all projects ├── pai-knowledge-os -> ~/projects/PAI/Notes/ ├── my-app -> ~/projects/my-app/Notes/ └── api-service -> ~/projects/api-service/Notes/ ``` -------------------------------- ### Clone, Install Dependencies, Build, and Link PAI CLI Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Follow these steps to clone the PAI repository, install its dependencies using Bun, build the project, and link the CLI globally for easy access. ```bash git clone https://github.com/mnott/PAI.git cd PAI bun install bun run build npm link # or: ln -s $(pwd)/dist/cli/index.mjs /usr/local/bin/pai ``` -------------------------------- ### Initialize and Connect McpServer Source: https://github.com/mnott/pai/blob/main/docs/mcp-skill-guide.md Initialize the `McpServer` with server details and instructions, then connect it to a transport. This example shows registering a prompt, resource, and tool. ```typescript import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; const server = new McpServer( { name: "my-server", version: "1.0.0" }, { instructions: thinRoutingTable } ); // Register a prompt server.prompt("skill-name", "One-line description", () => ({ messages: [{ role: "user", content: { type: "text", text: fullContent } }], })); // Register a resource server.resource("doc-name", "scheme://uri", { mimeType: "text/markdown" }, async () => ({ contents: [{ uri: "scheme://uri", mimeType: "text/markdown", text: docContent }], })); // Register a tool (unchanged by refactor) server.tool("tool-name", "Tool description", { param: z.string() }, async (args) => ({ content: [{ type: "text", text: "result" }], })); const transport = new StdioServerTransport(); await server.connect(transport); ``` -------------------------------- ### Install PAI MCP and Daemon Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Use these commands to install the MCP shim or the daemon with MCP. Restart Claude Code after installation. ```bash pai mcp install # Install MCP shim only pai daemon install # Install daemon + MCP together (recommended) ``` -------------------------------- ### Manual Build and Link PAI Source: https://context7.com/mnott/pai/llms.txt Clone the repository, install dependencies, build the project, and link it globally to make the `pai` command available. ```bash git clone https://github.com/mnott/PAI.git cd PAI bun install bun run build npm link # makes `pai` available globally ``` -------------------------------- ### Copy Agent Preferences File Source: https://github.com/mnott/pai/blob/main/templates/agent-prefs.example.md Command to copy the example agent preferences file to the user's configuration directory. ```bash cp ~/dev/ai/PAI/templates/agent-prefs.example.md ~/.config/pai/agent-prefs.md ``` -------------------------------- ### Implementation Task Workflow Source: https://github.com/mnott/pai/blob/main/templates/claude-md.template.md Example workflow for an implementation task, detailing parallel exploration with Haiku, parallel implementation with Sonnet, consolidation, and spotchecking. ```text User: "Add dark mode to the settings page" 1. Parallel exploration (haiku): - Find existing theme system - Find settings page components - Find CSS/styling patterns 2. Parallel implementation (sonnet): - Engineer: Add theme toggle component - Engineer: Update state management - Engineer: Add dark mode styles 3. Consolidate and review 4. Spotcheck: "Review implementation for edge cases" (haiku) 5. Present to user ``` -------------------------------- ### Development Build Commands Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Commands for installing dependencies, building the project, running in watch mode, testing, and linting. ```bash bun install ``` ```bash bun run build # Uses tsdown (NOT tsup) ``` ```bash bun run dev # Watch mode ``` ```bash bun run test # vitest ``` ```bash bun run lint # tsc --noEmit ``` -------------------------------- ### Correct Session Note Filename Examples Source: https://github.com/mnott/pai/blob/main/templates/pai-skill.template.md Examples of correctly formatted session note filenames, adhering to the NNNN - YYYY-MM-DD - Meaningful Description.md format. ```text 0027 - 2026-01-04 - Markdown Heading Fix.md 0028 - 2026-01-05 - Notification System Refactor.md 0029 - 2026-01-06 - Dark Mode Implementation.md ``` -------------------------------- ### Start PAI Daemon Source: https://github.com/mnott/pai/blob/main/README.md Start the PAI background daemon, which handles session indexing and serves MCP tools. It is configured to start automatically on login. ```bash pai daemon start ``` -------------------------------- ### Example Customized Agent Configuration Source: https://github.com/mnott/pai/blob/main/templates/agent-prefs.example.md A sample filled-in configuration file showing personal identity, directory restrictions, project mappings, notifications, voice, Git rules, and language/workflow preferences. ```markdown # My PAI Agent Preferences ## Your Identity - Name: Alice Chen - Role: Senior Full-Stack Engineer - Location: San Francisco, PST - Default Language: en ## Directory Restrictions Never Search: ~, ~/Library, ~/Downloads Always Use: ~/dev, ~/Projects, ~/.claude ## Project-Code Directory Mappings | Obsidian Project | Code Directory | |------------------|----------------| | Work Notes | ~/dev/company-product | | Learning | ~/projects/learning | | PAI | ~/dev/ai/PAI | ## Notification Preferences - Primary: WhatsApp to my number - Fallback: ntfy.sh/alice-projects-82934 ## Voice Configuration - Default: Kokoro (bm_george) - Engineer: Kokoro (bm_daniel) ## Git Commit Rules - Format: conventional commits - Include scope: true - AI signature: false ## Language Preferences 1. TypeScript / Node.js 2. Python (data pipelines) ## Workflow Preferences - Use plan mode: always - Verify before completion: always - Task file: tasks/todo.md ``` -------------------------------- ### Module Manifest Example Source: https://github.com/mnott/pai/blob/main/PLUGIN-ARCHITECTURE.md Defines the metadata for a PAI module, including its name, version, tier, and dependencies. ```json { "name": "pai-core", "displayName": "PAI Core", "description": "Core memory engine, session management, and project registry", "version": "0.7.0", "tier": "free", "required": true, "depends": [], "hooks": "hooks/hooks.json", "skills": ["Sessions", "Route", "Name"] } ``` -------------------------------- ### Planning Task Workflow Source: https://github.com/mnott/pai/blob/main/templates/claude-md.template.md Example workflow for a planning task, including parallel research with Haiku, parallel approach exploration with Sonnet, consolidation, and spotchecking. ```text User: "Plan the migration from REST to GraphQL" 1. Parallel research (haiku): - Current REST endpoint inventory - GraphQL schema best practices - Migration strategies 2. Parallel approach exploration (sonnet): - Architect: Big-bang migration plan - Architect: Incremental migration plan - Architect: Hybrid approach 3. Consolidate approaches 4. Spotcheck: "Compare these plans for risks and feasibility" (sonnet) 5. Present options to user ``` -------------------------------- ### Install PAI Hooks with CP Source: https://github.com/mnott/pai/blob/main/src/hooks/README.md Copies the hook scripts to the Claude Hooks directory and makes them executable. Use this if you do not need live updates. ```bash cp src/hooks/pre-compact.sh ~/.claude/Hooks/pai-pre-compact.sh cp src/hooks/session-stop.sh ~/.claude/Hooks/pai-session-stop.sh chmod +x ~/.claude/Hooks/pai-pre-compact.sh chmod +x ~/.claude/Hooks/pai-session-stop.sh ``` -------------------------------- ### PAI Daemon Configuration Example Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md This JSON object shows a sample configuration for the PAI daemon, specifying the storage backend, socket path, indexing interval, and PostgreSQL connection details. ```json { "storageBackend": "postgres", "socketPath": "/tmp/pai.sock", "indexIntervalSecs": 300, "postgres": { "host": "127.0.0.1", "port": 5432, "database": "pai", "user": "pai", "password": "pai" } } ``` -------------------------------- ### Budget-Aware Advisor Mode Statusline Display Source: https://github.com/mnott/pai/blob/main/README.md This example shows how the advisor mode label appears on the context line, indicating the current budget status and mode. ```text 💎 Context: 12K / 1000K (68%) │ 5h: 3% → 13:18 │ 1d: 5% / 8% │ 7d: strict 91% → Fr. 08:00 ``` -------------------------------- ### Get Project Details Source: https://context7.com/mnott/pai/llms.txt Use the `project_info` tool to fetch full metadata for a specific project, identified by its slug, alias, or number. ```json { tool: "project_info", params: { slug: "my-app" } } ``` -------------------------------- ### Example Lesson Entry Format Source: https://github.com/mnott/pai/blob/main/templates/claude-md.template.md Illustrates the required format for documenting lessons learned to prevent recurring mistakes. Include what went wrong, the rule to prevent it, and relevant metadata. ```markdown ## Lesson: Always verify API responses before processing **What went wrong**: Assumed API would always return expected shape, crashed on null **The rule**: Always add response validation and null checks before processing external data **Date**: YYYY-MM-DD **Project**: API Integration ``` -------------------------------- ### Install PAI Hooks with Symlink Source: https://github.com/mnott/pai/blob/main/src/hooks/README.md Creates symbolic links for the hook scripts, allowing for live updates when the source files change. This is useful for development. ```bash ln -sf "$(pwd)/src/hooks/pre-compact.sh" ~/.claude/Hooks/pai-pre-compact.sh ln -sf "$(pwd)/src/hooks/session-stop.sh" ~/.claude/Hooks/pai-session-stop.sh ``` -------------------------------- ### Git Commit Rules Example Source: https://github.com/mnott/pai/blob/main/templates/pai-skill.template.md Demonstrates correct and incorrect Git commit message formats. Avoid AI signatures and co-author lines for clean commit history. ```bash # CORRECT git commit -m "feat: Add session notes system" # WRONG git commit -m "feat: Add session notes system 🤖 Generated with Claude Code Co-Authored-By: Claude " ``` -------------------------------- ### PAI Daemon Management Commands Source: https://context7.com/mnott/pai/llms.txt Commands for installing, managing, and viewing logs for the PAI daemon, which runs as `com.pai.pai-daemon`. ```bash # Install daemon + MCP server registration (restart Claude Code after) pai daemon install ``` ```bash # Runtime management pai daemon status # check health + socket + PID pai daemon restart # graceful restart pai daemon logs # view /tmp/pai-daemon.log pai daemon logs -f # tail -f the log pai daemon serve # run in foreground (dev/debug mode) pai daemon uninstall # remove launchd service ``` -------------------------------- ### PAI Daemon Configuration File Source: https://context7.com/mnott/pai/llms.txt Example configuration file (`~/.config/pai/config.json`) for the PAI daemon, detailing settings for storage backend, socket path, indexing, auto-saving, wake-up context, database connection, and search parameters. ```json # Daemon configuration: ~/.config/pai/config.json cat ~/.config/pai/config.json # { # "storageBackend": "postgres", // "sqlite" | "postgres" # "socketPath": "/tmp/pai.sock", # "indexIntervalSecs": 300, // 5 minutes # "autoSaveInterval": 15, // mid-session save every 15 prompts # "wakeupL1Count": 3, // recent notes to load for L1 wake-up # "postgres": { # "host": "127.0.0.1", # "port": 5432, # "database": "pai", # "user": "pai", # "password": "pai" # }, # "search": { # "mode": "keyword", # "rerank": true, # "recencyBoostDays": 90, # "defaultLimit": 10, # "snippetLength": 200 # } # } ``` -------------------------------- ### Research Task Workflow Source: https://github.com/mnott/pai/blob/main/templates/claude-md.template.md Example workflow for a research task, involving decomposition, parallel execution of queries using Haiku, consolidation, and spotchecking. ```text User: "Research the best practices for API rate limiting" 1. Decompose into 4 parallel queries: - Rate limiting algorithms (haiku) - Implementation patterns (haiku) - Popular library options (haiku) - Real-world case studies (haiku) 2. Launch all 4 in ONE message 3. Consolidate results 4. Spotcheck: "Review this summary for completeness and accuracy" (haiku) 5. Present to user ``` -------------------------------- ### Get project details with PAI CLI Source: https://github.com/mnott/pai/blob/main/MANUAL.md Retrieve detailed information about a specific project by its name. Useful for understanding a project's status and configuration. ```bash pai project info my-app ``` -------------------------------- ### Configure Identity File for PAI Source: https://github.com/mnott/pai/blob/main/README.md Create `~/.pai/identity.txt` to define your persona and working style for PAI. This file is read at every session start. ```text Matthias. Principal engineer. Work across TypeScript, Dart, and shell scripting. Projects: PAI (AI infrastructure), RingsADay (Flutter app), Scribe (MCP server). Prefer concise explanations, hate unnecessary hedging. ``` -------------------------------- ### List all projects using PAI CLI Source: https://github.com/mnott/pai/blob/main/MANUAL.md Use this command to view all registered projects within PAI. It helps in getting an overview of your indexed projects. ```bash pai project list ``` -------------------------------- ### Start PostgreSQL with pgvector Source: https://context7.com/mnott/pai/llms.txt Run PostgreSQL with the pgvector extension in a Docker container for full PAI mode. Ensure the container is named `pai-postgres` and ports are mapped correctly. ```bash docker run -d \ --name pai-postgres \ -e POSTGRES_USER=pai \ -e POSTGRES_PASSWORD=pai \ -e POSTGRES_DB=pai \ -p 127.0.0.1:5432:5432 \ pgvector/pgvector:pg17 ``` -------------------------------- ### Fact-Checking Protocol Example Source: https://github.com/mnott/pai/blob/main/templates/pai-skill.template.md When presenting information from external AI sources, always verify claims against official sources and mark unverified claims with '⚠️ Unverified'. Prefer official documentation, government sites, or company sites for verification. ```text According to Gemini, the limit is 500 requests/day. ⚠️ Unverified - checking official docs... ``` -------------------------------- ### Incorrect Session Note Filename Examples Source: https://github.com/mnott/pai/blob/main/templates/pai-skill.template.md Examples of incorrectly formatted session note filenames that should be avoided. These violate the required naming conventions. ```text 0027 - 2026-01-04 - Appstore.md ❌ Project name, not descriptive 0027 - 2026-01-04 - New Session.md ❌ Placeholder, not descriptive 0027_2026-01-04_appstore.md ❌ Wrong format AND not descriptive ``` -------------------------------- ### Get Specific File Content Source: https://context7.com/mnott/pai/llms.txt Retrieves the full content of a specific file from the index by its project and path. Use after a compact search to get detailed file content. ```typescript { tool: "memory_get", params: { project: "pai", path: "src/daemon/scheduler.ts" } } ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/mnott/pai/blob/main/templates/agent-prefs.example.md Illustrative examples of Git commit messages following the conventional commits format, including feature, fix, refactor, docs, and test types with optional scopes. ```markdown Conventional Commits Examples: - `feat(api): add user authentication endpoint` - `fix(database): resolve connection pooling issue` - `refactor(ui): simplify button component logic` - `docs(readme): update installation instructions` - `test(auth): add JWT validation tests` ``` -------------------------------- ### PAI Natural Language Triggers Source: https://context7.com/mnott/pai/llms.txt Examples of natural language phrases that activate specific PAI skills. ```bash # Natural language triggers also work: "plan my week" # → /plan skill "review my work today" # → /review skill "tweet about what I shipped" # → /share skill "journal this thought" # → /journal skill "reconstruct last session" # → /reconstruct skill ``` -------------------------------- ### Promote Session Note to Project Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Promote a session note into a new project, specifying the source session and the target project path. ```bash pai project promote --from-session ~/.pai/sessions/0012 --to ~/projects/new-project ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Prints the root path of a project, allowing shell navigation to its directory. ```bash cd $(pai project cd my-app) ``` -------------------------------- ### Task Decomposition Decision Tree Source: https://github.com/mnott/pai/blob/main/templates/claude-md.template.md A flowchart to guide task decomposition and agent selection based on complexity, requirements, and available models. ```text START │ ├─ Can this be decomposed into independent parts? │ ├─ YES → Launch parallel agents (haiku first) │ └─ NO → Continue │ ├─ Is this simple verification/lookup? │ ├─ YES → Single agent with haiku │ └─ NO → Continue │ ├─ Does this require code writing? │ ├─ YES → Engineer agent with sonnet │ └─ NO → Continue │ ├─ Does this require deep reasoning? │ ├─ YES → Consider opus (but try sonnet first) │ └─ NO → Use haiku or sonnet │ └─ After completion: ALWAYS spotcheck SPECIAL CASES: - Dependencies between parts → Parallelize independent parts, sequence dependent ones - Uncertain decomposition → Launch exploration agent (haiku) to suggest breakdown - Budget concerns → More parallel haiku agents before considering larger models NEVER do significant work directly in main context. ``` -------------------------------- ### Perform PAI Backup and Restore Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Back up the registry, configuration, and PostgreSQL database with `pai backup`. Restore from a backup using `pai restore `, with an option to skip the database restore. ```bash pai backup ``` ```bash pai restore ``` -------------------------------- ### Create a backup with PAI CLI Source: https://github.com/mnott/pai/blob/main/MANUAL.md Generate a full backup of your PAI data, including the project registry, configuration, and PostgreSQL dump. Backups are stored in `~/.pai/backups/`. ```bash pai backup ``` -------------------------------- ### Switching Budget Advisor Modes Source: https://github.com/mnott/pai/blob/main/README.md These commands demonstrate how to manually switch between different budget advisor modes or reset to automatic mode. Changes take effect on the next prompt. ```bash /budget auto — reset to auto (budget-driven) /budget mode normal — force normal mode /budget force haiku — force all subagents to haiku /Advisor auto — same, via skill (note: capital A) /Advisor mode strict — force strict mode "go full power" — normal mode (plain language) "be conservative" — conservative mode "lock it down" — critical mode "back to auto" — auto mode ``` -------------------------------- ### Configure Language and Framework Preferences Source: https://github.com/mnott/pai/blob/main/templates/agent-prefs.example.md Specify ranked language preferences, preferred web frameworks (backend/frontend), build tools, and database choices. ```markdown ## Language Preferences (ranked) 1. TypeScript / JavaScript (primary) 2. Python (data/ML work) 3. [Other language] ## Web Framework - Backend: [Express, Fastify, Django, FastAPI, etc.] - Frontend: [React, Vue, Svelte, etc.] - Build tool: [Vite, Webpack, esbuild, etc.] ## Database - Primary: [PostgreSQL, MySQL, SQLite, etc.] - Cache: [Redis, Memcached, etc.] - Vector DB: [Pinecone, Supabase pgvector, etc.] ## Cloud Platform - Primary: [AWS, Azure, GCP, etc.] - Preferred services: [Lambda, CloudRun, etc.] ``` -------------------------------- ### Scan and Check Registry Statistics Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Use `registry scan` to discover new projects and `registry stats` to view statistics about the registry. ```bash pai registry scan ``` ```bash pai registry stats ``` -------------------------------- ### Anti-Criteria Definition Example Source: https://github.com/mnott/pai/blob/main/templates/pai-skill.template.md When planning work, define what must NOT happen using the 'ISC-A' prefix. Anti-criteria are verifiable requirements, similar to positive criteria. ```text ISC-A1: No personal data in exported files ``` -------------------------------- ### Suggest Zettelkasten Link Targets Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Get suggestions for link targets in your Zettelkasten, weighted by semantics, tags, and graph neighborhood, using `zettel suggest`. ```bash pai zettel suggest "My Seed Note" --limit 5 ``` -------------------------------- ### Create Full Backup Source: https://context7.com/mnott/pai/llms.txt Generate a timestamped backup of the PAI knowledge base, including the registry, configuration, and PostgreSQL dump. ```bash # Create a full backup pai backup # Creates: ~/.pai/backups/2026-04-13T14-30-00/ # registry.db — SQLite project registry # config.json — daemon configuration # federation.db — SQLite fallback (if using simple mode) # pai_dump.sql — pg_dump of PostgreSQL (full mode) ``` -------------------------------- ### Configure Notification Preferences Source: https://github.com/mnott/pai/blob/main/templates/agent-prefs.example.md Set up primary and fallback notification channels (e.g., WhatsApp, ntfy.sh) and select important events for which to receive notifications. Ensure ntfy.sh topics are long and random for security. ```markdown ## Primary Notification Channel - Method: WhatsApp (via Whazaa MCP) - Contact: [your phone number or contact name] ## Fallback Channel (when WhatsApp unavailable) - Method: ntfy.sh (cloud pubsub) - Topic: [your-private-ntfy-topic] # Must be >20 chars or use cryptographically random ## Important Events to Notify - [ ] Long-running task started (>30 seconds) - [ ] Task completed successfully - [ ] Task failed or encountered error - [ ] Manual intervention required ``` -------------------------------- ### Example Cross-Project Tunnel Output Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Illustrates the output format for detected concept-tunnel pairs, including the concept name, involved projects, and a tunnel strength score. ```json [ { "concept": "rate limiting", "projects": ["pai-daemon", "whazaa-mcp", "ringsaday-backend"], "tunnel_strength": 0.87 } ] ``` -------------------------------- ### Build Hooks Script Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Use these commands to build the PAI hooks. The `bun run build` command builds everything, while `node scripts/build-hooks.mjs` builds only the hooks. ```bash bun run build # Builds everything including hooks ``` ```bash node scripts/build-hooks.mjs # Build hooks only ``` -------------------------------- ### Claude Memory Search Prompts Source: https://github.com/mnott/pai/blob/main/README.md These are example prompts you can give to Claude to search its memory. Claude automatically uses the memory_search tool when PAI is configured as an MCP server. ```text "Search your memory for authentication" "What do you know about the database migration?" "Find where we discussed the notification system" ``` -------------------------------- ### Open Obsidian vault with PAI CLI Source: https://github.com/mnott/pai/blob/main/MANUAL.md Launch the Obsidian application and open your configured vault. This provides quick access to your notes. ```bash pai obsidian open ``` -------------------------------- ### List and Cleanup Sessions Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Use `session list` to view sessions, optionally filtering by project. `session cleanup` automatically names and organizes sessions into dated folders. ```bash pai session list --project my-app ``` ```bash pai session cleanup ``` -------------------------------- ### Restore from Backup Source: https://context7.com/mnott/pai/llms.txt Restore the PAI knowledge base from a specified backup directory. Options exist to exclude PostgreSQL data for cleaner migrations. ```bash # Restore from backup pai restore ~/.pai/backups/2026-04-13T14-30-00 # Restore registry only (skip PostgreSQL — useful for fresh instance) pai restore ~/.pai/backups/2026-04-13T14-30-00 --no-postgres ``` ```bash # Migrate SQLite → PostgreSQL after switching storage modes pai daemon migrate ``` -------------------------------- ### List sessions for a project with PAI CLI Source: https://github.com/mnott/pai/blob/main/MANUAL.md View all recorded sessions associated with a specific project. Sessions represent distinct work periods or contexts. ```bash pai session list --project my-app ``` -------------------------------- ### Prompt to Configure Auto-Compact Source: https://github.com/mnott/pai/blob/main/README.md Use this prompt to instruct Claude Code to add the `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` setting to your `~/.claude/settings.json` file. ```text > Add `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` set to `80` to the `env` block in `~/.claude/settings.json`. This enables durable auto-compact that survives restarts. Do not touch `~/.claude.json` — that file gets overwritten on startup. After saving, confirm the setting is in place and tell me to restart Claude Code. ``` -------------------------------- ### Source Citation Example Source: https://github.com/mnott/pai/blob/main/templates/pai-skill.template.md For legal, regulatory, or technical claims, always include links to official sources. Format citations as '[Source Name](URL)' or inline links, prioritizing official documentation. ```text The GDPR requires consent for processing personal data ([GDPR Art. 6](https://gdpr-info.eu/art-6-gdpr/)). ``` -------------------------------- ### Create a Custom Skill Source: https://github.com/mnott/pai/blob/main/user-extensions/README.md To add a custom skill, create a directory for your skill and include a SKILL.md file. This file defines the skill's name and description, and its content. ```markdown user-extensions/skills/MySkill/SKILL.md ``` ```markdown --- name: MySkill description: "What the skill does. USE WHEN user says 'trigger phrase'." --- ## My Skill Instructions Your skill content here... ``` -------------------------------- ### Session Summary Pipeline Workflow Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Illustrates the flow of data and processing steps within the session summary pipeline, from hook triggers to daemon processing and note updates. ```text Stop or PreCompact hook fires │ ├── Hook reads minimal data (session_id, transcript_path, cwd) ├── Hook pushes { type: "session-summary", payload: {...} } to work queue └── Hook exits (sub-second) ⬇ Daemon worker loop picks up the item session-summary-worker.ts │ ├── Reads JSONL transcript (500K limit for stop, 200K for compact) ├── Reads recent git log (last 20 commits) ├── Strips ANTHROPIC_API_KEY from environment ├── Spawns headless Claude CLI (Opus for stop, Sonnet for compact) ├── Prompt requests: TOPIC: line + Work Done / Key Decisions / Known Issues / Next Steps ├── Compares TOPIC: against existing note title (Jaccard similarity < 30% → new note) └── Writes or updates session note in project's Notes directory ⬇ If topic-detect was also enqueued topic-detect-worker.ts │ ├── Extracts recent user messages from JSONL ├── Runs BM25 topic shift detector against PAI memory DB └── Records topic boundary marker (used by next session-summary run) ``` -------------------------------- ### Register Resource and Directory Entry Source: https://github.com/mnott/pai/blob/main/docs/mcp-skill-guide.md Add an entry to the resource directory and register the resource with `server.resource()`. The directory entry maps a name to a URI. ```typescript // Step 2: Add to resource directory in instructions `| API reference | pai://api-reference | // Step 3: Register the resource server.resource( "api-reference", "pai://api-reference", { mimeType: "text/markdown" }, async () => ({ contents: [{ uri: "pai://api-reference", mimeType: "text/markdown", text: apiReferenceContent, }], }) ); ``` -------------------------------- ### Read Project TODO File Source: https://context7.com/mnott/pai/llms.txt Use the `project_todo` tool to read a project's TODO file, prioritizing the 'Continue' section if found. It searches multiple standard locations for the TODO file. ```json { tool: "project_todo", params: { project: "my-app" } } ``` -------------------------------- ### Project Discovery and Continuation Source: https://github.com/mnott/pai/blob/main/templates/claude-md.template.md Outlines the process for discovering and resuming PAI-managed projects. It involves querying PAI for project details, reading TODO files, and presenting continuation context. ```markdown 1. Query PAI immediately: - `mcp__pai__registry_search` with the project name or keyword - If ambiguous, `mcp__pai__project_list` to show options 2. If a matching project is found: - Call `mcp__pai__project_info` to get its root path and status - Read the project's TODO.md (check `/Notes/TODO.md` and `/.claude/Notes/TODO.md`) - Look for a `## Continue` section — this is the handover from the last session ``` -------------------------------- ### Register a Resource Source: https://github.com/mnott/pai/blob/main/docs/mcp-skill-guide.md Register a resource with a name, URI, configuration, and an async function to retrieve its contents. The `mimeType` should be specified in the configuration. ```typescript server.resource( "aesthetic", "pai://aesthetic", { mimeType: "text/markdown" }, async () => ({ contents: [{ uri: "pai://aesthetic", mimeType: "text/markdown", text: aestheticGuideContent, }], }) ); ``` -------------------------------- ### Create PAI Identity File Source: https://context7.com/mnott/pai/llms.txt Create the identity file for the L0 context layer, defining the principal's role, skills, projects, and preferences. ```bash cat > ~/.pai/identity.txt << 'EOF' Alice. Principal engineer. TypeScript, Python, Go. Projects: auth-service, data-pipeline, frontend-app. Prefer direct answers, no hedging. EOF ``` -------------------------------- ### Project Management CLI Commands Source: https://context7.com/mnott/pai/llms.txt Command-line interface equivalents for managing project registries, including listing, adding, detecting, auditing health, tagging, aliasing, archiving, and navigating projects. ```bash pai project list pai project list --status active pai project info my-app pai project add /home/user/new-project # register a new project pai project detect # detect from CWD pai project health # audit all paths pai project health --category stale # only stale projects pai project tag my-app infrastructure # add a tag pai project alias my-app ma # add a short alias pai project archive old-api # archive a project pai project move old-api /new/path # update root path cd $(pai project cd my-app) # navigate to project ``` -------------------------------- ### Restore Command Source: https://github.com/mnott/pai/blob/main/ARCHITECTURE.md Restores the project's data from a specified backup directory. The --no-postgres flag can be used to skip PostgreSQL restoration. ```bash pai restore ~/.pai/backups/2026-02-25T14-30-00 ``` ```bash pai restore ~/.pai/backups/2026-02-25T14-30-00 --no-postgres ``` -------------------------------- ### Quick Lookup for TODO.md and Session Notes Source: https://github.com/mnott/pai/blob/main/templates/pai-skill.template.md Use these bash commands to quickly find the TODO.md file and the latest session note for continuing previous work. The first command checks common locations for TODO.md, while the second lists session notes by modification time. ```bash # Find TODO.md — check for ## Continue section at the top cat Notes/TODO.md 2>/dev/null || cat TODO.md 2>/dev/null ``` ```bash # Find latest session note (4-digit format) ls -t Notes/*.md 2>/dev/null | grep -E '^Notes/[0-9]{4}' | head -1 ```