Expose Claude as a Plan 9 filesystem.
"For 40 years, Unix piped static text. Now we can pipe dynamic queries to intelligence."
This project exposes Claude CLI as a 9P filesystem, letting you interact with AI using standard Unix tools.
/claude/
├── ask # Stateless query (write prompt, read response)
├── stream # Streaming responses
├── chat/
│ ├── new # Write to create session, read to get session ID
│ └── {id}/ # Session directory (created dynamically)
│ ├── prompt # Write message, read response
│ └── history # Read conversation history
├── config/
│ ├── model # Read/write model name
│ └── system # Read/write system prompt
└── log # Read interaction history (last 100)
- Go 1.20+
- Claude CLI
- plan9port
# Clone and build ai-9p
git clone https://github.com/yourusername/ai-9p
cd ai-9p
go build -o ai-9p .
# Install plan9port (if not already installed)
git clone https://github.com/9fans/plan9port ~/projects/plan9port
cd ~/projects/plan9port
./INSTALLStart the 9P server:
./ai-9p &
# ai-9p serving on localhost:5640# Simple question
echo "What is 2+2?" | 9p -a localhost:5640 rdwr claude/ask
# → 4
# Streaming response
echo "Write a haiku" | 9p -a localhost:5640 rdwr claude/stream
# → A circuit hums low / Binary rivers flowing / Silicon dreams wake# Create a new session
echo "start" | 9p -a localhost:5640 rdwr claude/chat/new
# → 51000
# Send messages (Claude remembers context)
echo "My name is Alice" | 9p -a localhost:5640 rdwr claude/chat/51000/prompt
echo "What is my name?" | 9p -a localhost:5640 rdwr claude/chat/51000/prompt
# → Your name is Alice
# Read conversation history
9p -a localhost:5640 read claude/chat/51000/history# Read current model
9p -a localhost:5640 read claude/config/model
# Set system prompt
echo "You are a pirate" | 9p -a localhost:5640 write claude/config/system# View recent interactions (timestamped)
9p -a localhost:5640 read claude/logAdd to ~/.zshrc:
export PLAN9=~/projects/plan9port
export PATH=$PATH:$PLAN9/bin
# Quick AI query
ai() {
echo "$*" | 9p -a localhost:5640 rdwr claude/ask
}
# Example usage
ai "What is the capital of France?"
git diff | ai "summarize these changes"┌─────────────┐ ┌──────────────┐ ┌───────────┐
│ User/Shell │────▶│ 9P Server │────▶│ Claude CLI│
│ 9p/cat/echo│◀────│ (Go) │◀────│ │
└─────────────┘ └──────────────┘ └───────────┘
Plan 9's vision: everything is a file. The filesystem is the universal API.
LLMs communicate via text streams. The intersection is natural:
- No SDKs or libraries needed
- Standard Unix tools work (cat, echo, pipes)
- Composable with other programs
- Network transparent via 9P
- Stateful sessions as directories
MIT