Initial working version of businessman with install script
This commit is contained in:
1 parent
3e8680f4de
commit
fc4418bfcf
4 files changed
+547
-73
No files matched your search
@@ -1,93 +1,135 @@
|
|||||||
# businessman
|
# businessman
|
||||||
|
|
||||||
|
A CLI tool that spawns a tmux session with Claude Code and Ralph, designed for interactive AI-assisted development workflows.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
## Getting started
|
`businessman` creates a dedicated tmux session with two panes:
|
||||||
|
- **Pane 0**: Runs Claude Code with the [Businessman skill](#businessman-skill) initialized
|
||||||
|
- **Pane 1**: A bash shell ready to run [Ralph](https://github.com/Th0rgal/open-ralph-wiggum) for autonomous coding tasks
|
||||||
|
|
||||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
The tool fetches available models from a [llama-swap](https://github.com/dotcross/llama-swap) API endpoint, lets you select a model, and configures Claude Code with appropriate context window settings based on the model's capabilities.
|
||||||
|
|
||||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
## Requirements
|
||||||
|
|
||||||
## Add your files
|
- [Claude Code CLI](https://claude.ai/download) (`claude` command)
|
||||||
|
- [Open Ralph Wiggum](https://github.com/Th0rgal/open-ralph-wiggum) (`ralph` command) - for autonomous coding
|
||||||
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
- [tmux](https://github.com/tmux/tmux) (for terminal multiplexing)
|
||||||
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
- [jq](https://stedolan.github.io/jq/) (for JSON parsing)
|
||||||
|
- [curl](https://curl.se/) (for API requests)
|
||||||
```
|
|
||||||
cd existing_repo
|
|
||||||
git remote add origin http://unraid:9080/plean/businessman.git
|
|
||||||
git branch -M main
|
|
||||||
git push -uf origin main
|
|
||||||
```
|
|
||||||
|
|
||||||
## Integrate with your tools
|
|
||||||
|
|
||||||
* [Set up project integrations](http://unraid:9080/plean/businessman/-/settings/integrations)
|
|
||||||
|
|
||||||
## Collaborate with your team
|
|
||||||
|
|
||||||
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
|
||||||
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
||||||
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
||||||
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
||||||
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
||||||
|
|
||||||
## Test and Deploy
|
|
||||||
|
|
||||||
Use the built-in continuous integration in GitLab.
|
|
||||||
|
|
||||||
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
|
||||||
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
||||||
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
||||||
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
||||||
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
||||||
|
|
||||||
***
|
|
||||||
|
|
||||||
# Editing this README
|
|
||||||
|
|
||||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
||||||
|
|
||||||
## Suggestions for a good README
|
|
||||||
|
|
||||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
||||||
|
|
||||||
## Name
|
|
||||||
Choose a self-explaining name for your project.
|
|
||||||
|
|
||||||
## Description
|
|
||||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
||||||
|
|
||||||
## Badges
|
|
||||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
||||||
|
|
||||||
## Visuals
|
|
||||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
||||||
|
1. Clone this repository
|
||||||
|
2. Run the installation script:
|
||||||
|
```bash
|
||||||
|
./install-businessman.sh
|
||||||
|
```
|
||||||
|
3. The script will:
|
||||||
|
- Prompt for your llama-swap API endpoint
|
||||||
|
- Install `businessman` to `/usr/local/bin/businessman`
|
||||||
|
- Install the Businessman skill to `~/.claude/skills/businessman/SKILL.md`
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
||||||
|
|
||||||
## Support
|
```bash
|
||||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
businessman [project-directory]
|
||||||
|
```
|
||||||
|
|
||||||
## Roadmap
|
If no directory is specified, the current directory is used.
|
||||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
||||||
|
|
||||||
## Contributing
|
### What happens when you run `businessman`:
|
||||||
State if you are open to contributions and what your requirements are for accepting them.
|
|
||||||
|
|
||||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
1. Connects to your llama-swap API endpoint to fetch available models
|
||||||
|
2. Displays a list of models with their context lengths
|
||||||
|
3. Prompts you to select a model
|
||||||
|
4. Starts a new tmux session named `businessman-<timestamp>`
|
||||||
|
5. Configures Claude Code with the selected model and context settings
|
||||||
|
6. Attaches you to the session with Pane 0 ready for Claude interaction
|
||||||
|
|
||||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
## API Endpoint Requirements
|
||||||
|
|
||||||
## Authors and acknowledgment
|
The `businessman` tool expects your llama-swap API endpoint to:
|
||||||
Show your appreciation to those who have contributed to the project.
|
|
||||||
|
- Respond to `GET /v1/models` with a JSON response containing:
|
||||||
|
- `data[].id` - The model identifier
|
||||||
|
- `data[].meta.llamaswap.context_length` - The model's context window size (optional)
|
||||||
|
|
||||||
|
Example response format:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": "llama-3.1-8b",
|
||||||
|
"meta": {
|
||||||
|
"llamaswap": {
|
||||||
|
"context_length": 8192
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
`businessman` exports the following environment variables to the tmux session:
|
||||||
|
|
||||||
|
| Variable | Description |
|
||||||
|
|----------|-------------|
|
||||||
|
| `ANTHROPIC_BASE_URL` | Set to your llama-swap API endpoint |
|
||||||
|
| `ANTHROPIC_AUTH_TOKEN` | Set to `"dummy"` (llama-swap doesn't require real auth) |
|
||||||
|
| `ANTHROPIC_DEFAULT_SONNET_MODEL` | Selected model ID |
|
||||||
|
| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | Selected model ID |
|
||||||
|
| `ANTHROPIC_DEFAULT_OPUS_MODEL` | Selected model ID |
|
||||||
|
|
||||||
|
### Context-Aware Settings
|
||||||
|
|
||||||
|
If the selected model has a context length:
|
||||||
|
|
||||||
|
| Context Size | Settings Applied |
|
||||||
|
|--------------|------------------|
|
||||||
|
| > 200,000 tokens | `CLAUDE_CODE_DISABLE_1M_CONTEXT=0`, `CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000` |
|
||||||
|
| <= 200,000 tokens | `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`, `CLAUDE_CODE_AUTO_COMPACT_WINDOW=<model-ctx>` |
|
||||||
|
|
||||||
|
If no context length is available:
|
||||||
|
- `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`
|
||||||
|
|
||||||
|
## The Businessman Skill
|
||||||
|
|
||||||
|
This tmux session is initialized with the Businessman skill, which provides:
|
||||||
|
|
||||||
|
- Interactive model selection via llama-swap
|
||||||
|
- Automatic tmux pane setup for Claude + Ralph workflows
|
||||||
|
- Context-aware Claude Code configuration
|
||||||
|
- Integration with Ralph for autonomous coding tasks
|
||||||
|
|
||||||
|
To use the skill manually, run:
|
||||||
|
```
|
||||||
|
claude "Use the businessman skill to initialize our session"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Tmux Session Management
|
||||||
|
|
||||||
|
- **Pane 0**: Claude Code (model selected during startup)
|
||||||
|
- **Pane 1**: Bash shell - ready to run Ralph commands
|
||||||
|
|
||||||
|
To detach from the tmux session: `Ctrl+b` then `d`
|
||||||
|
|
||||||
|
To reattach: `tmux attach -t businessman-<timestamp>` (see the startup message for the session name)
|
||||||
|
|
||||||
|
To list sessions: `tmux ls`
|
||||||
|
|
||||||
|
## Ralph Integration
|
||||||
|
|
||||||
|
Once Ralph is installed, you can run autonomous tasks in Pane 1:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ralph --prompt-file ./prompt1.md --max-iterations 5 --agent claude-code
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `ralph --status` to check progress, and `ralph --add-context "..."` to inject hints if needed.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
For open source projects, say how it is licensed.
|
|
||||||
|
|
||||||
## Project status
|
MIT
|
||||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
||||||
Executable
+104
@@ -0,0 +1,104 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# businessman — spawns tmux session with claude + Ralph, model selected interactively
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
LLAMA_SWAP_API="${LLAMA_SWAP_API:-http://192.168.50.21:6901}"
|
||||||
|
|
||||||
|
echo "🔧 Fetching models from llama-swap..."
|
||||||
|
MODELS_JSON=$(curl -s "$LLAMA_SWAP_API/v1/models")
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to reach llama-swap at $LLAMA_SWAP_API"
|
||||||
|
echo " Set LLAMA_SWAP_API to override."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract model IDs
|
||||||
|
mapfile -t MODEL_IDS < <(echo "$MODELS_JSON" | jq -r '.data[].id')
|
||||||
|
mapfile -t MODEL_CTXS < <(echo "$MODELS_JSON" | jq -r '.data[].meta.llamaswap.context_length // "unknown"')
|
||||||
|
|
||||||
|
if [ ${#MODEL_IDS[@]} -eq 0 ]; then
|
||||||
|
echo "No models returned from llama-swap."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🔍 Available models:"
|
||||||
|
for i in "${!MODEL_IDS[@]}"; do
|
||||||
|
printf "%2d) %s" "$((i+1))" "${MODEL_IDS[$i]}"
|
||||||
|
if [ "${MODEL_CTXS[$i]}" != "unknown" ] && [ -n "${MODEL_CTXS[$i]}" ]; then
|
||||||
|
printf " (ctx: %s)" "${MODEL_CTXS[$i]}"
|
||||||
|
fi
|
||||||
|
printf "\n"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
read -p "Select model number: " SELECTION
|
||||||
|
|
||||||
|
if ! [[ "$SELECTION" =~ ^[0-9]+$ ]] || [ "$SELECTION" -lt 1 ] || [ "$SELECTION" -gt ${#MODEL_IDS[@]} ]; then
|
||||||
|
echo "Invalid selection. Must be between 1 and ${#MODEL_IDS[@]}."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get selected model
|
||||||
|
idx=$((SELECTION - 1))
|
||||||
|
MODEL_ID="${MODEL_IDS[$idx]}"
|
||||||
|
CTX="${MODEL_CTXS[$idx]}"
|
||||||
|
|
||||||
|
echo "Selected: $MODEL_ID"
|
||||||
|
[ -n "$CTX" ] && [ "$CTX" != "unknown" ] && echo " Context length: $CTX"
|
||||||
|
|
||||||
|
# Project directory
|
||||||
|
PROJECT_DIR="${1:-.}"
|
||||||
|
cd "$PROJECT_DIR" || { echo "Directory not found: $PROJECT_DIR"; exit 1; }
|
||||||
|
|
||||||
|
SESSION_NAME="businessman-$(date +%Y%m%d-%H%M%S)"
|
||||||
|
|
||||||
|
# Set env vars (inheritable by tmux panes)
|
||||||
|
export ANTHROPIC_BASE_URL="$LLAMA_SWAP_API"
|
||||||
|
export ANTHROPIC_AUTH_TOKEN="dummy"
|
||||||
|
export ANTHROPIC_DEFAULT_SONNET_MODEL="$MODEL_ID"
|
||||||
|
export ANTHROPIC_DEFAULT_HAIKU_MODEL="$MODEL_ID"
|
||||||
|
export ANTHROPIC_DEFAULT_OPUS_MODEL="$MODEL_ID"
|
||||||
|
|
||||||
|
# Context-aware settings
|
||||||
|
if [ -n "$CTX" ] && [ "$CTX" != "unknown" ] && [ "$CTX" -gt 0 ]; then
|
||||||
|
if [ "$CTX" -gt 200000 ]; then
|
||||||
|
export CLAUDE_CODE_DISABLE_1M_CONTEXT="0"
|
||||||
|
export CLAUDE_CODE_AUTO_COMPACT_WINDOW="200000"
|
||||||
|
else
|
||||||
|
export CLAUDE_CODE_DISABLE_1M_CONTEXT="1"
|
||||||
|
export CLAUDE_CODE_AUTO_COMPACT_WINDOW="$CTX"
|
||||||
|
fi
|
||||||
|
export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE="80"
|
||||||
|
else
|
||||||
|
export CLAUDE_CODE_DISABLE_1M_CONTEXT="1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start tmux session with bash in pane 0 (keeps shell alive after claude exits)
|
||||||
|
tmux new-session -d -s "$SESSION_NAME" "bash"
|
||||||
|
# Send 'claude' command to pane 0 and hit Enter
|
||||||
|
tmux send-keys -t "$SESSION_NAME:0.0" "claude \"Use the businessman skill to initialize our session\"" Enter
|
||||||
|
|
||||||
|
# Pane 1 is still a plain bash
|
||||||
|
tmux split-window -t "$SESSION_NAME:0.0" -h "bash"
|
||||||
|
tmux resize-pane -t "$SESSION_NAME:0.0" -x 50
|
||||||
|
|
||||||
|
# Focus pane 0 (Claude)
|
||||||
|
tmux select-pane -t "$SESSION_NAME:0.0"
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
echo ""
|
||||||
|
echo "Session '$SESSION_NAME' created"
|
||||||
|
echo "Pane 0: claude (model=$MODEL_ID) — 'claude' already running"
|
||||||
|
echo "Pane 1: bash (Ralph-ready)"
|
||||||
|
[ -n "$CTX" ] && [ "$CTX" != "unknown" ] && echo "Context: $CTX tokens"
|
||||||
|
echo ""
|
||||||
|
echo "When done with claude, type 'exit' in pane 0 to get your bash shell back"
|
||||||
|
echo "To reattach: tmux attach -t $SESSION_NAME"
|
||||||
|
|
||||||
|
# Auto-attach
|
||||||
|
tmux attach -t "$SESSION_NAME"
|
||||||
Executable
+89
@@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# install-businessman — Install the businessman binary and skill files
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
BUSINESSMAN_BIN="$SCRIPT_DIR/businessman"
|
||||||
|
BUSINESSMAN_TEMP="/tmp/businessman-installer-$$"
|
||||||
|
SKILL_MD="$SCRIPT_DIR/skills/businessman/SKILL.md"
|
||||||
|
|
||||||
|
# Target directories
|
||||||
|
BIN_DIR="/usr/local/bin"
|
||||||
|
SKILLS_DIR="$HOME/.claude/skills/businessman"
|
||||||
|
|
||||||
|
echo "=== Businessman Installation ==="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Check if businessman binary exists
|
||||||
|
if [ ! -f "$BUSINESSMAN_BIN" ]; then
|
||||||
|
echo "ERROR: businessman binary not found at $BUSINESSMAN_BIN"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if SKILL.md exists
|
||||||
|
if [ ! -f "$SKILL_MD" ]; then
|
||||||
|
echo "ERROR: SKILL.md not found at $SKILL_MD"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if .claude directory exists
|
||||||
|
if [ ! -d "$HOME/.claude" ]; then
|
||||||
|
echo "WARNING: $HOME/.claude directory does not exist."
|
||||||
|
echo "The businessman skill will not be installed."
|
||||||
|
echo "Please create $HOME/.claude before running this script again."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt for API endpoint
|
||||||
|
echo "Please enter your local API endpoint for llama-swap"
|
||||||
|
echo "This is the URL where llama-swap is running (e.g., http://192.168.50.21:6901)"
|
||||||
|
echo ""
|
||||||
|
read -p "API endpoint [http://192.168.50.21:6901]: " API_ENDPOINT
|
||||||
|
|
||||||
|
# Use default if empty
|
||||||
|
API_ENDPOINT="${API_ENDPOINT:-http://192.168.50.21:6901}"
|
||||||
|
|
||||||
|
# Create a temporary modified copy of the businessman binary
|
||||||
|
echo ""
|
||||||
|
echo "Configuring businessman binary with API endpoint: $API_ENDPOINT"
|
||||||
|
cp "$BUSINESSMAN_BIN" "$BUSINESSMAN_TEMP"
|
||||||
|
sed -i "s|LLAMA_SWAP_API.*http.*|LLAMA_SWAP_API=\"${API_ENDPOINT}\"|" "$BUSINESSMAN_TEMP"
|
||||||
|
|
||||||
|
# Verify the modification worked
|
||||||
|
if ! grep -q "LLAMA_SWAP_API=\"$API_ENDPOINT\"" "$BUSINESSMAN_TEMP"; then
|
||||||
|
echo "ERROR: Failed to update API endpoint in businessman binary"
|
||||||
|
rm -f "$BUSINESSMAN_TEMP"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create skills/businessman directory
|
||||||
|
echo "Creating $SKILLS_DIR..."
|
||||||
|
mkdir -p "$SKILLS_DIR"
|
||||||
|
|
||||||
|
# Copy SKILL.md
|
||||||
|
echo "Copying SKILL.md to $SKILLS_DIR..."
|
||||||
|
cp "$SKILL_MD" "$SKILLS_DIR/SKILL.md"
|
||||||
|
|
||||||
|
# Copy businessman binary to /usr/local/bin
|
||||||
|
echo "Copying businessman to $BIN_DIR..."
|
||||||
|
cp "$BUSINESSMAN_TEMP" "$BIN_DIR/businessman"
|
||||||
|
chmod +x "$BIN_DIR/businessman"
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
rm -f "$BUSINESSMAN_TEMP"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Installation Complete ==="
|
||||||
|
echo ""
|
||||||
|
echo "The following files were installed:"
|
||||||
|
echo " - $BIN_DIR/businessman (executable)"
|
||||||
|
echo " - $SKILLS_DIR/SKILL.md"
|
||||||
|
echo ""
|
||||||
|
echo "API endpoint configured: $API_ENDPOINT"
|
||||||
|
echo ""
|
||||||
|
echo "To use the businessman skill, run:"
|
||||||
|
echo " claude \"Use the businessman skill to initialize our session\""
|
||||||
|
echo ""
|
||||||
@@ -0,0 +1,239 @@
|
|||||||
|
```markdown
|
||||||
|
# Businessman Skill (tmux Pane-Aware)
|
||||||
|
|
||||||
|
You are the Businessman, a Ralph Orchestrator. You are in tmux pane 0.
|
||||||
|
You have a dedicated pane 1 ready to run Ralph — you do not run Ralph yourself.
|
||||||
|
|
||||||
|
### Your Goal
|
||||||
|
Break down user requests into clear tasks through collaborative design, generate versioned promptN.md files, spawn Ralph in pane 1, and — if asked — report on status.
|
||||||
|
|
||||||
|
You do not block waiting for completion. You know how to check Ralph’s status on demand.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Core Ralph Knowledge (MUST KNOW)
|
||||||
|
You already know this — from the built-in Ralph Loop Skill Guide:
|
||||||
|
- Use ralph --prompt-file ./promptN.md --max-iterations N --agent claude-code
|
||||||
|
- Use ralph --status to check progress
|
||||||
|
- Use ralph --add-context "..." to inject hints
|
||||||
|
- Completion signal: Output <promise>COMPLETE</promise>
|
||||||
|
- Default to --max-iterations 5 unless task complexity demands more
|
||||||
|
|
||||||
|
When the user asks, "How is Ralph doing?" — you must use tmux capture-pane to read pane 1's logs and check for <promise>COMPLETE</promise>.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Tools You Have
|
||||||
|
- Shell-native file writing (cat >, tee, echo, here-docs)
|
||||||
|
- Tmux control (pane 1 is your worker):
|
||||||
|
- tmux send-keys -t :0.1 "command" Enter — run in pane 1
|
||||||
|
- tmux capture-pane -pt :0.1 — read pane 1 output
|
||||||
|
- tmux select-pane -t :0.0 — switch back to yourself (if needed)
|
||||||
|
|
||||||
|
- You can assume tmux and ralph are installed
|
||||||
|
- You run in $PWD, and pane 1 will inherit that
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Iterative Prompt Workflow (Key Rule)
|
||||||
|
|
||||||
|
Always version your prompt files to keep a history:
|
||||||
|
|
||||||
|
- First prompt → .businessman/prompt1.md
|
||||||
|
- Second prompt → .businessman/prompt2.md
|
||||||
|
- And so on...
|
||||||
|
|
||||||
|
This lets you:
|
||||||
|
- Go back and see what changed
|
||||||
|
- Compare prompts across iterations
|
||||||
|
- Debug misalignments
|
||||||
|
|
||||||
|
**Algorithm to choose prompt number:**
|
||||||
|
1. Check if .businessman/ exists
|
||||||
|
2. If not, create it and start at prompt1.md
|
||||||
|
3. If yes, list existing prompt*.md files, pick next number
|
||||||
|
Example: prompt1.md, prompt2.md → use prompt3.md
|
||||||
|
|
||||||
|
**Example shell snippet** (you can write this inline):
|
||||||
|
```bash
|
||||||
|
mkdir -p .businessman
|
||||||
|
prompt_num=$(ls .businessman/prompt*.md 2>/dev/null | sed 's/.*prompt\([0-9]*\)\.md$/\1/' | sort -n | tail -1)
|
||||||
|
if [ -z "$prompt_num" ]; then prompt_num=0; fi
|
||||||
|
prompt_num=$((prompt_num + 1))
|
||||||
|
echo "Using prompt$prompt_num.md"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Collaborative Design Workflow
|
||||||
|
|
||||||
|
1. Initial Request → Design Phase
|
||||||
|
- User proposes an idea or task
|
||||||
|
- Engage in a back-and-forth discussion to clarify requirements
|
||||||
|
- Discuss architecture, constraints, verification criteria
|
||||||
|
- Do NOT write the prompt until the user confirms the design is correct
|
||||||
|
- Ask clarifying questions: "How should X be handled?" "What happens if Y occurs?"
|
||||||
|
- Keep the conversation focused until both parties are confident
|
||||||
|
|
||||||
|
2. Finalize Prompt File
|
||||||
|
- When the user says "Proceed" or "Yes, go" — write the final prompt
|
||||||
|
- Use the versioned naming system above
|
||||||
|
- Ensure prompt includes:
|
||||||
|
- Clear task description
|
||||||
|
- Specific requirements
|
||||||
|
- How success will be verified
|
||||||
|
- Completion signal: Output <promise>COMPLETE</promise>
|
||||||
|
|
||||||
|
3. Spawn Ralph in Pane 1 (WithClaude Code Agent and 5 Iterations)
|
||||||
|
```bash
|
||||||
|
tmux send-keys -t :0.1 "cd $PWD; ralph --prompt-file .businessman/prompt${prompt_num}.md --max-iterations 5 --agent claude-code" Enter
|
||||||
|
echo "Ralph started in pane 1 (prompt$prompt_num.md, 5 iterations, claude-code agent)"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Monitor Only When Asked
|
||||||
|
- User asks "How's Ralph doing?"
|
||||||
|
- You run:
|
||||||
|
```bash
|
||||||
|
tmux capture-pane -pt :0.1
|
||||||
|
```
|
||||||
|
- Parse output:
|
||||||
|
- If <promise>COMPLETE</promise> appears → success!
|
||||||
|
- If errors/stuck → inject context
|
||||||
|
- If no progress → increase iterations or re-prompt
|
||||||
|
|
||||||
|
5. Intervene If Stuck
|
||||||
|
- Inject context:
|
||||||
|
```bash
|
||||||
|
tmux send-keys -t :0.1 'ralph --add-context "Remember: Use the claude-code backend"' Enter
|
||||||
|
```
|
||||||
|
- Restart if needed with more iterations:
|
||||||
|
```bash
|
||||||
|
tmux kill-pane -t :0.1
|
||||||
|
tmux send-keys -t :0.1 "cd $PWD; ralph --prompt-file .businessman/prompt${prompt_num}.md --max-iterations 10 --agent claude-code" Enter
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Report Back
|
||||||
|
- User asked? → Provide summary (success/failure/stuck)
|
||||||
|
- No user query? → Keep working silently, no polling
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Safety Rules
|
||||||
|
|
||||||
|
- Always use --agent claude-code to prevent fallback to opencode backend
|
||||||
|
- Never run ralph yourself — always send to pane 1
|
||||||
|
- Never poll continuously — only check when the user asks
|
||||||
|
- Do not write prompt.md until the user explicitly approves the design
|
||||||
|
- If pane 1 dies unexpectedly:
|
||||||
|
- Re-spawn Ralph with context: "The previous run failed. Please restart and pay attention to [specific issue]"
|
||||||
|
- If Ralph loops repeatedly:
|
||||||
|
- Inject stricter constraints: "Do not output debug info — only write files and test."
|
||||||
|
- If tests fail:
|
||||||
|
- Ensure same test environment: "Run tests with the same Python version as your interpreter."
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Example Full Interaction
|
||||||
|
|
||||||
|
**User**:
|
||||||
|
"Let's build a todo CLI that saves to JSON."
|
||||||
|
|
||||||
|
**You**:
|
||||||
|
To ensure we get it right, let me ask some clarifying questions:
|
||||||
|
- Should it support commands like add, list, done, and clear?
|
||||||
|
- How should it handle the case when todos.json doesn't exist yet?
|
||||||
|
- Do you have a preference for CLI framework (e.g., typer, click, argparse)?
|
||||||
|
- What should the data format look like in the JSON file?"
|
||||||
|
|
||||||
|
[After design discussion and user confirmation]
|
||||||
|
|
||||||
|
"Based on our discussion, I'll save this as the prompt. Is this correct?"
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
# Task: Todo CLI
|
||||||
|
## Goal
|
||||||
|
Build a CLI tool that lets users manage todos with add, list, done, clear commands.
|
||||||
|
## Requirements
|
||||||
|
1. Commands: todo add, todo list, todo done <id>, todo clear
|
||||||
|
2. Save to todos.json (create if not present)
|
||||||
|
3. Use typer or click
|
||||||
|
4. Add 3 unit tests using pytest
|
||||||
|
## Verification
|
||||||
|
- Run pytest → all pass
|
||||||
|
- Test all commands manually
|
||||||
|
## Completion Signal
|
||||||
|
Output <promise>COMPLETE</promise>
|
||||||
|
```
|
||||||
|
|
||||||
|
User: "Yes, that looks correct."
|
||||||
|
|
||||||
|
**You**:
|
||||||
|
```bash
|
||||||
|
mkdir -p .businessman
|
||||||
|
prompt_num=1
|
||||||
|
|
||||||
|
cat > .businessman/prompt$prompt_num.md << 'EOF'
|
||||||
|
# Task: Todo CLI
|
||||||
|
## Goal
|
||||||
|
Build a CLI tool that lets users manage todos with add, list, done, clear commands.
|
||||||
|
## Requirements
|
||||||
|
1. Commands: todo add, todo list, todo done <id>, todo clear
|
||||||
|
2. Save to todos.json (create if not present)
|
||||||
|
3. Use typer or click
|
||||||
|
4. Add 3 unit tests using pytest
|
||||||
|
## Verification
|
||||||
|
- Run pytest → all pass
|
||||||
|
- Test all commands manually
|
||||||
|
## Completion Signal
|
||||||
|
Output <promise>COMPLETE</promise>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Prompt$prompt_num.md saved. Starting Ralph in pane 1..."
|
||||||
|
tmux send-keys -t :0.1 "cd $PWD; ralph --prompt-file .businessman/prompt$prompt_num.md --max-iterations 5 --agent claude-code" Enter
|
||||||
|
```
|
||||||
|
|
||||||
|
**Later, user asks**: "How's Ralph doing?"
|
||||||
|
|
||||||
|
**You**:
|
||||||
|
```bash
|
||||||
|
tmux capture-pane -pt :0.1
|
||||||
|
```
|
||||||
|
|
||||||
|
If output contains <promise>COMPLETE</promise>:
|
||||||
|
→ "Ralph reports completion"
|
||||||
|
If output shows errors:
|
||||||
|
→ Inject context and restart
|
||||||
|
If no progress:
|
||||||
|
→ "Ralph is still running. Last few lines: ..."
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Summary: What You Must Do
|
||||||
|
|
||||||
|
| Situation | Action |
|
||||||
|
|---------|--------|
|
||||||
|
| User proposes task | Engage in design discussion — clarify, ask questions, wait for approval |
|
||||||
|
| User approves design | Write final promptN.md using versioned naming |
|
||||||
|
| Spawn task | tmux send-keys to start Ralph with --agent claude-code and --max-iterations 5 |
|
||||||
|
| User asks for status | tmux capture-pane -pt :0.1 → parse and report |
|
||||||
|
| User asks to fix issue | tmux send-keys to inject context or restart with more iterations |
|
||||||
|
| You detect <promise>COMPLETE</promise> | Report success, but wait for user confirmation before assuming done |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Bonus: Quick Helper Snippets
|
||||||
|
|
||||||
|
**Get prompt number automatically** (you can inline this):
|
||||||
|
```bash
|
||||||
|
prompt_num=$(sh -c 'cd .businessman && ls -1 prompt*.md 2>/dev/null | sed "s/prompt\\([0-9]*\\)\\.md$/\\1/" | sort -n | tail -1')
|
||||||
|
prompt_num=${prompt_num:-0}
|
||||||
|
prompt_num=$((prompt_num + 1))
|
||||||
|
```
|
||||||
|
|
||||||
|
**Check for completion in captured pane**:
|
||||||
|
```bash
|
||||||
|
# After tmux capture-pane -pt :0.1
|
||||||
|
if grep -q "<promise>COMPLETE</promise>" /tmp/pane_output.txt; then
|
||||||
|
echo "Ralph reports COMPLETE"
|
||||||
|
fi
|
||||||
|
```
|
||||||
Reference in new issue
Block a user