cd-permanent
Scannednpx machina-cli add skill YoniChechik/claude-code-config/cd-permanent --openclawInstructions
Step 1: Parse and Validate Path
Parse $ARGUMENTS as the target path.
If empty: Show usage: /cd-permanent <path>
Step 2: Check if Path is Within Project
# Get project root and target real path
PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
TARGET_PATH=$(realpath -m "$ARGUMENTS" 2>/dev/null || echo "$ARGUMENTS")
Check if $TARGET_PATH starts with $PROJECT_ROOT:
- If YES: Continue to Step 3
- If NO: Continue to Step 4
Step 3: Change Directory (Within Project)
cd "$TARGET_PATH"
pwd
Confirm: "Changed directory to: [new path]"
Step 4: Outside Project
Cannot change directory outside the project tree. Claude Code enforces staying within the base directory where the session started.
Source
git clone https://github.com/YoniChechik/claude-code-config/blob/main/skills/cd-permanent/SKILL.mdView on GitHub Overview
This skill lets you change directories in the current session, but only inside the project tree. It enforces staying within the repository root to prevent accidental navigation outside the project.
How This Skill Works
The command parses the provided path, determines the project root using git rev-parse --show-toplevel (or falls back to the current directory), and resolves the target path with realpath. If the target path starts with the project root, it executes cd and prints a confirmation; otherwise it blocks navigation outside the project tree with a clear message.
When to Use It
- You want to move around a repository quickly while ensuring all navigation stays within the project root.
- Working on a multi-subdirectory project and you need to consistently stay inside the base project during a session.
- You want to prevent accidental directory changes to areas outside the repository while coding.
- Setting up a repeatable session workflow where all directory changes are confined to the project tree.
- Exploring a codebase with a strict boundary to the base project directory in a single, persistent session.
Quick Start
- Step 1: Run cd-permanent with a target path, e.g., cd-permanent src/utils
- Step 2: The command resolves and validates the path against the project root
- Step 3: If inside the project, it changes directory and prints: Changed directory to: [new path]
Best Practices
- Always provide a valid path; if ARGUMENTS is empty, usage is shown (/cd-permanent <path>).
- Rely on realpath -m to normalize the target path before comparison.
- Verify that the resolved path starts with the detected PROJECT_ROOT before changing directories.
- Test edge cases with relative paths and symlinks to ensure they resolve inside the project.
- Use within a single session to maintain a consistent project-scoped navigation history.
Example Use Cases
- cd-permanent src/utils
- cd-permanent assets/images
- cd-permanent docs
- cd-permanent ./scripts/setup
- cd-permanent /path/to/project/src