scope
npx machina-cli add skill NorthShoreAutomation/trellis/scope --openclawUser Input
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty).
Instructions
1. Parse Intent
Read the natural language description from $ARGUMENTS. This description defines the entire scope of work.
If $ARGUMENTS is empty, ask the user: "What would you like to work on? Describe the feature, fix, or change."
2. Detect Existing Branch
- Run
git branch --show-currentto get the current branch name - If on main or master: Proceed to step 3 (create new branch)
- If on a feature branch (any non-main/master branch):
- Inform the user: "You're on branch
<branch-name>. Start a new scope (creates new branch from main) or add work to this branch?" - If new scope: Run
git checkout main && git pullthen proceed to step 3 - If add to current branch: Skip branch creation, proceed directly to step 5
- Inform the user: "You're on branch
3. Create Branch
-
Determine scope type by analyzing the description for keywords:
Type Keywords Branch prefix Bug fix fix, bug, broken, error, crash, issue, wrong, failing fix/Refactor refactor, cleanup, reorganize, simplify, restructure refactor/Chore chore, update deps, ci, config, docs, lint, format, bump chore/Feature (default — anything not matching above) feat/Keyword matching is case-insensitive. If multiple types match, prefer the first match in order: fix, refactor, chore, feat.
-
Generate short name: Extract 2-4 key words from the description, convert to kebab-case. Drop filler words (the, a, an, for, to, and, of, in, on, with).
- "add user authentication" ->
feat/user-authentication - "fix login timeout error" ->
fix/login-timeout - "refactor database connection pooling" ->
refactor/db-connection-pooling - "update CI configuration" ->
chore/update-ci-config
- "add user authentication" ->
-
Create and checkout the branch:
git checkout -b <type>/<short-name>If branch creation fails (e.g., branch already exists), append a numeric suffix:
<type>/<short-name>-2
4. Beads Integration (Optional)
- Check if the
bdcommand is available:command -v bd - If available:
- Map scope type to beads issue type: feature ->
feature, fix ->bug, refactor ->task, chore ->task - Create a tracking issue:
bd create --title="<description>" --type=<type> --priority=2 - Store the returned issue ID for reference in the PR description
- If
bd createfails, warn but continue without beads tracking
- Map scope type to beads issue type: feature ->
- If not available: Continue without beads. Do not prompt the user about this.
5. Propose Approach
Analyze the codebase and the description to formulate an implementation approach:
-
Read relevant files to understand the current state of the code
-
Identify which files will likely need to be created or modified
-
Present a concise approach summary to the user:
SCOPE: <type>/<short-name> BRANCH: <branch-name> BEADS: <issue-id> (or "not tracked" if beads unavailable) APPROACH: - <bullet 1: what will be done> - <bullet 2: key files affected> - <bullet 3: any notable decisions> Proceed? [yes/no] -
Wait for user confirmation. This is the ONLY human interaction point. After approval, everything runs autonomously.
-
If the user says no or requests changes, revise the approach and re-present.
6. Invoke Implement
After user approval, invoke the implement skill to execute the work autonomously:
Use the Skill tool to invoke: /trellis:implement --approved <description>
The --approved flag signals that scope already obtained user confirmation, so implement skips its own proposal step.
If the Skill tool invocation fails, fall back to direct implementation:
- Execute the work directly based on the approved approach
- Commit changes incrementally with descriptive messages
- Follow conventional commit format:
<type>(scope): description
7. Push and Create PR
After implementation completes:
-
Ensure all changes are committed:
- Run
git statusto check for uncommitted changes - If uncommitted changes exist, stage and commit them:
git add <specific changed files> git commit -m "<type>(<scope>): <summary of remaining changes>"
- Run
-
Push to remote:
git push -u origin $(git branch --show-current)If push fails, report the error and stop.
-
Create the PR:
- Analyze all commits on the branch:
git log main..HEAD --oneline(usemasterifmaindoesn't exist) - Analyze files changed:
git diff main..HEAD --stat - Create the PR:
gh pr create --title "<concise title>" --body "$(cat <<'EOF' ## Summary <1-3 bullet points describing what this scope accomplishes> ## Changes <list of specific changes made, grouped by area> ## Test Plan <how to verify the changes work correctly> ## Related Issues <beads issue ID if created, or "N/A"> EOF )" - Use a concise title (under 70 characters) following conventional commit style
- If PR creation fails, report the error but do not retry automatically
- Analyze all commits on the branch:
8. Report Results
Display a completion summary:
SCOPE COMPLETE: <type>/<short-name>
Branch: <branch-name>
PR: <pr-url>
Beads: <issue-id> (or "not tracked")
Commits: <count>
Files changed: <count>
Next:
• /trellis:release — merge and publish when ready
• /trellis:codemap — map or update your codebase (recommended for new projects)
Notes
- Scope is the PRIMARY entry point for all new work in Trellis
- The two-command lifecycle is:
/trellis:scope(branch + build + verify + PR) then/trellis:release(merge + tag + publish) - Only ONE user confirmation is required (step 5). Everything before it is automatic setup; everything after it is autonomous execution.
- If the user provides additional flags in
$ARGUMENTS, pass them through to/trellis:implement - Never force-push. Never push to main/master directly.
- If
ghCLI is not available or not authenticated, warn the user and skip PR creation. The branch will still be pushed.
Source
git clone https://github.com/NorthShoreAutomation/trellis/blob/main/skills/scope/SKILL.mdView on GitHub Overview
Scope automates starting a new scope of work by creating a type-prefixed Git branch, implementing the work autonomously, pushing changes, and opening a PR. It derives the scope type from keywords in your description ($ARGUMENTS) and generates a concise, kebab-case branch name. If you’re on main, it creates a new branch from main; if you’re on a feature branch, you can start fresh or add to the existing branch.
How This Skill Works
The skill analyzes the $ARGUMENTS input to determine the scope type (fix, feat, refactor, chore) and extracts a short, kebab-case name. It checks your current Git branch, creates or reuses a branch from main as needed, and then proceeds to implement changes and open a PR after user confirmation. Optional beads integration can map the scope to a beads issue and attach the ID to the PR description.
When to Use It
- You want to start a new feature with a dedicated scope and branch
- You need to fix a bug in isolation and create a fix/ branch
- You want to refactor or clean up code with a separate scope
- You’re on another feature branch and want to start a fresh scope from main
- You want an automated PR created after autonomous implementation
Quick Start
- Step 1: Describe the work in $ARGUMENTS (e.g., 'add user authentication')
- Step 2: Review the proposed scope type and branch name, then approve
- Step 3: The system creates the branch, implements autonomously, pushes, and opens a PR
Best Practices
- Clearly describe the feature, bug, or change in $ARGUMENTS to guide type detection
- Keep the description concise and include keywords for accurate type mapping
- Ensure you’re on the intended starting branch (main) or allow scoping from main
- Review the generated short-name and PR before approving autonomous apply
- If beads are available, consider linking the issue for traceability; otherwise continue without beads
Example Use Cases
- add user authentication -> feat/user-authentication
- fix login timeout error -> fix/login-timeout
- refactor database connection pooling -> refactor/db-connection-pooling
- update CI configuration -> chore/update-ci-config
- design new search feature -> feat/design-new-search-feature