-
Notifications
You must be signed in to change notification settings - Fork 374
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Add a new ralph-init command (or extend ralph-setup) to initialize Ralph in an existing project directory without creating a new folder or running git init.
Problem Statement
Currently, both ralph-setup and ralph-import always create a new project directory:
# ralph-setup always creates new folder
mkdir -p "$PROJECT_NAME"
cd "$PROJECT_NAME"
git init # Dangerous for existing repos!
# ralph-import does the same
ralph-setup "$project_name"
cd "$project_name"Users with existing projects have no native way to add Ralph. The current workaround is cumbersome:
# Workaround: create temp project and copy .ralph/ folder
ralph-import my-project/prd.md temp-ralph
cp -r temp-ralph/.ralph my-project/
rm -rf temp-ralphThis is a highly requested feature - see issue #85 with 8+ users asking for this capability.
Proposed CLI Interface
# Initialize Ralph in current directory (no new folder, no git init)
cd my-existing-project
ralph-init
# Initialize with PRD conversion
ralph-init --from prd.md
# Initialize in specific directory
ralph-init --dir /path/to/existing/project
# Force overwrite existing .ralph/ folder
ralph-init --forceExpected Behavior
| Command | Creates folder? | Runs git init? | Converts PRD? |
|---|---|---|---|
ralph-setup project |
Yes | Yes | No |
ralph-import prd.md project |
Yes | Yes | Yes |
ralph-init |
No | No | No |
ralph-init --from prd.md |
No | No | Yes |
Implementation Approach
- Create new
ralph_init.shscript - Add safety checks:
- Warn if
.ralph/already exists (require--forceto overwrite) - Detect if directory is a git repo (skip git init)
- Verify templates directory exists
- Warn if
- Create only
.ralph/structure without touching project root - Optionally run PRD conversion with
--fromflag - Add
ralph-initto install.sh for global availability - Update documentation
Proposed Implementation
#!/bin/bash
# ralph_init.sh - Initialize Ralph in existing project
set -e
TARGET_DIR="${1:-.}"
PRD_FILE=""
FORCE=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--from) PRD_FILE="$2"; shift 2 ;;
--dir) TARGET_DIR="$2"; shift 2 ;;
--force) FORCE=true; shift ;;
*) shift ;;
esac
done
cd "$TARGET_DIR"
# Safety check
if [[ -d ".ralph" && "$FORCE" != "true" ]]; then
echo "Error: .ralph/ already exists. Use --force to overwrite."
exit 1
fi
# Create .ralph structure (no git init!)
mkdir -p .ralph/{specs/stdlib,examples,logs,docs/generated}
# Copy templates
cp "$TEMPLATES_DIR/PROMPT.md" .ralph/
cp "$TEMPLATES_DIR/fix_plan.md" .ralph/@fix_plan.md
cp "$TEMPLATES_DIR/AGENT.md" .ralph/@AGENT.md
# Optional PRD conversion
if [[ -n "$PRD_FILE" ]]; then
# Run conversion logic from ralph_import.sh
convert_prd "$PRD_FILE"
fi
echo "✅ Ralph initialized in $(pwd)"Acceptance Criteria
-
ralph-initcreates.ralph/structure in current directory - Does NOT create new project folder
- Does NOT run
git init(respects existing repos) -
--from prd.mdconverts PRD using Claude Code -
--dir pathallows specifying target directory -
--forceoverwrites existing.ralph/folder - Warns if
.ralph/already exists without--force - Added to
install.shfor global installation - Documentation updated in README.md
- Tests added for new command
Related Issues
- Best way to drop into a existing project? #85 - Best way to drop into an existing project? (user request)
- Ralph not starting on existing project #97 - Ralph not starting on existing project
- Feature Proposal: Monorepo Support & .ralphrc Configuration File #64 - Feature Proposal: Monorepo Support & .ralphrc Configuration File
Notes
This would significantly improve Ralph's adoption for users with existing codebases, which is likely the majority of real-world use cases.
blooop, sleemCode, danshaw and Calfredopcoderabbitai
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request