Structure determines action.
Palace is a self-improving agent orchestration layer for Claude Code that enables Recursive Hierarchical Self Improvement (RHSI).
Instead of manually planning your next steps, ask Palace. It analyzes your project state, suggests intelligent actions, and learns from your workflow patterns over time.
You: /pal-next
β
Palace: Analyzes project β Suggests actions
β
Claude: Executes your selection
β
Palace: Logs results
β
You: /pal-next (again)
β
Palace: Suggests next steps based on what was just done
β
... improvement accelerates
Each iteration builds on the last. Palace remembers what you've done and suggests logical next steps.
- π― Intelligent Suggestions: Analyzes git status, recent history, and project files to suggest what to do next
- π¦ Lightweight Context: Sends metadata (1-2KB), not full files - leaves 99% of context for Claude to explore
- π Session Management: Resume complex workflows, export/import sessions, track progress
- π Mask System: Apply expert personas for specialized workflows (testing, security, architecture)
- β‘ Error Recovery: Automatic retry with backoff, graceful degradation, session checkpointing
- π§ͺ Test-Driven: Enforces TDD by default - every change requires tests
- π Strict Mode: Validates tests before completion - ensures code quality (use
--yoloto disable) - π¨ Flexible Selection: Choose actions with numbers, ranges, modifiers, or natural language
# Clone and install
git clone git@github.com:Zorlin/palace.git
cd palace
# Install dependencies (using uv recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt
# Install Palace commands into Claude Code
python palace.py install# Initialize in your project
cd ~/my-project
python palace.py init
# Start Claude Code
claude
# Ask Palace what to do next
> /pal-nextWhat happens:
- Palace analyzes your project state
- Claude suggests multiple actionable next steps
- You select which actions to execute
- Claude performs the work
- Palace logs the results
- Repeat
/pal-next- suggestions get smarter
| Command | Description |
|---|---|
pal next |
Suggest next steps (RHSI core) |
pal new <name> |
Create a new project |
pal scaffold |
Add best practices to existing project |
pal test |
Run project tests |
pal sessions |
List saved sessions |
pal cleanup |
Clean up old sessions |
pal export <id> |
Export session for sharing |
pal import <file> |
Import a session |
pal analyze |
Self-analysis of Palace metrics |
pal install |
Install Palace into Claude Code |
Palace enforces strict mode by default, ensuring all tests pass before a session completes.
- During Execution: Claude can freely write and edit files
- At Completion: Palace detects which tests are affected by modified files
- Validation: Runs only the relevant tests (not the entire suite)
- Enforcement: Session cannot complete until all affected tests pass
# Default: Strict mode enabled
pal next
# Disable strict mode (YOLO mode)
pal next --yolo
# Also works with all commands
pal scaffold --yolo- Prevents broken code: Catches test failures immediately
- Fast feedback: Runs only affected tests, not the full suite
- TDD enforcement: Aligns with Golden Rule #1
- CI/CD ready: Code that completes in strict mode is deploy-ready
Use --yolo to disable test validation:
- For rapid prototyping
- When tests don't exist yet
- For exploration and experimentation
- When you know what you're doing
Note: YOLO mode logs a warning to history for audit purposes.
Control which AI models Palace uses with provider override flags.
- Normal mode (
pal next): Uses Claude Sonnet 4.5 (high quality) - Turbo mode (
pal next -t): Uses GLM-4.6 (cost-efficient)
# Use Claude models even in turbo mode (higher quality, higher cost)
pal next -t --claude
# Use GLM even in normal mode (lower cost, faster)
pal next --glm
# Combine with other flags
pal next -t --claude --yolo # Quality + speed--claude (ENGAGE mode)
- You want max quality in turbo mode
- Complex reasoning tasks need Claude
- "I want to spend money for better results"
--glm (Economy mode)
- Cost savings in normal mode
- Simple tasks don't need Claude
- Fast iteration on straightforward work
Both flags work with all commands that invoke Claude.
- Quick Start - Get up and running in 5 minutes
- User Guide - Complete guide to using Palace
- Examples - Real-world workflow examples
- Specification - Technical specification and architecture
- Mask System - Expert personas and composition
- Error Recovery - Resilience and retry strategies
- Architecture - System design and implementation
- Roadmap - Future plans and features
- Contributing - How to contribute
Palace follows two golden rules:
Every feature, every change, every improvement MUST have tests.
- Tests are written FIRST
- Tests define the spec
- No commits without green tests
- Test coverage is mandatory, not optional
Offer options, don't dictate solutions.
- Present multiple valid paths forward
- The user decides what to do
- Never restrict outputs artificially
- Let the user steer - you're a tool, not a boss
$ claude
> /pal-next
ACTIONS:
1. Write tests for user registration
2. Implement registration endpoint
3. Update API documentation
Select: 1
[Claude writes comprehensive tests]
> /pal-next
ACTIONS:
1. Implement registration endpoint (tests exist)
2. Add input validation
3. Update API documentation
Select: 1 2
[Claude implements to pass tests]# Export your workflow
$ python palace.py export pal-abc123 -o feature-workflow.json
# Teammate imports and continues
$ python palace.py import feature-workflow.json
$ python palace.py next --resume pal-xyz789# Simple numbers
> 1 2 3
# Ranges
> 1-5
# With modifiers
> 1 2 (use TypeScript and follow TDD)
# Natural language (uses LLM)
> do the first and third but skip the integration testsPalace is a thin orchestration layer - it doesn't replace Claude, it enhances it:
- Gathers lightweight context (file metadata, git status, recent actions)
- Generates focused prompts for Claude to analyze
- Lets Claude use full capabilities to explore and execute
- Logs actions to history for learning and iteration
- Suggests smarter next steps based on what was just done
Total overhead: ~1-2KB of context, leaving 99%+ for Claude to work.
βββββββββββββββββββββββββββββββββββββββββββ
β User β
β β /pal-next β
ββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββ
β Palace (Orchestration) β
β β’ Gather context (metadata only) β
β β’ Build prompt β
β β’ Invoke Claude Code CLI β
ββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββ
β Claude (Execution) β
β β’ Read files as needed β
β β’ Analyze and plan β
β β’ Use tools (Edit, Write, Bash, etc.) β
β β’ Suggest next actions β
ββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββ
β Palace (Logging & Learning) β
β β’ Log actions to history β
β β’ Save session state β
β β’ Learn patterns over time β
βββββββββββββββββββββββββββββββββββββββββββ
Palace requires MCP server registration to handle permissions during RHSI loops. This is required for pal next to work properly.
Add Palace to your ~/.claude.json under the mcpServers key:
{
"mcpServers": {
"palace": {
"type": "stdio",
"command": "/path/to/palace/.venv/bin/python",
"args": [
"/path/to/palace/palace.py"
],
"env": {}
}
}
}Replace /path/to/palace with your actual Palace installation path.
# Install as MCP server (Claude Desktop)
uv run mcp install palace.py
# For Claude Code CLI
claude mcp add palace --scope user \
$(pwd)/.venv/bin/python \
$(pwd)/palace.pyIf pal next shows no output or immediately displays a prompt without any Claude response, the MCP server is likely not configured. Verify by checking:
jq '.mcpServers.palace' ~/.claude.jsonIf this returns null, Palace MCP is not registered.
Palace's handle_permission tool uses Haiku to assess safety of commands during RHSI loops.
- Python 3.10+
- Claude Code CLI (install guide)
- Anthropic API key
- uv (recommended) or pip
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Write tests first (TDD is mandatory)
- Ensure all tests pass:
pytest tests/ -v - Follow Semantic Line Breaks
- Submit a pull request
See CONTRIBUTING.md for detailed guidelines.
Palace is licensed under the GNU Affero General Public License v3.0. See LICENSE for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Claude Code: anthropics/claude-code
Ready to let Palace guide your workflow?
cd your-project
python palace.py init
claude
> /pal-nextLet the recursive improvement begin! ποΈ