Worktree Task

    by Harshit Vashistha

    1

    Execute coding tasks in isolated git worktrees to keep your main branch clean and experiments safe.

    Free

    Security scanned

    Works with the AI Agents you already use

    Worktree Task

    Example session with this skill installed

    Try refactoring the AuthController to use the new UserService, but do it in a separate worktree so I don't lose my current progress on the login UI.

    • Read your context and instructions
    • Compiled the worktree task

    I have completed the refactor in an isolated worktree. The main directory remains untouched.

    Task Report: AuthController Refactor

    I initialized a new worktree at ../api-service-wt-20250522-1430 on branch wt/20250522-1430. The following changes were implemented and tested.

    MetricResult
    Files Changedsrc/controllers/AuthController.ts, src/services/UserService.ts
    Lines Added42
    Lines Removed18
    Test Suitenpm test
    Test Results12 Passed, 0 Failed

    Changes Summary

    • Injected UserService into AuthController constructor.
    • Replaced direct database calls in login and register methods with service calls.
    • Updated unit tests in AuthController.test.ts to mock the new service dependency.
    • Verified that all authentication middleware remains compatible with the new structure.

    Next steps

    • Keep: Run git merge wt/20250522-1430 to bring these changes into your current branch.
    • Discard: I will remove the worktree and delete the temporary branch.
    • Continue: Tell me what else needs to be adjusted within this isolated environment.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Running experimental refactors or risky migrations directly in your working directory leads to broken states and lost productivity. This skill automates the creation of isolated git worktrees to execute tasks on separate branches without touching your current files.

    What it does

    • Isolated execution creates a temporary directory and branch for every task.
    • Environment validation checks git status and branch state before starting work.
    • Automated testing identifies and runs test suites within the worktree to validate changes.
    • Impact reporting calculates exact line counts and file diffs against the base branch.
    • Workflow cleanup handles the merging or deletion of worktrees based on your feedback.

    How it works

    1. Initialize the skill by providing a coding task or refactor request.
    2. Setup involves the agent creating a new worktree at ../<repo>-wt-<id> on a fresh branch.
    3. Execution occurs strictly within the worktree folder, including all commits and test runs.
    4. Review the generated report containing diff stats and test results.
    5. Finalize by choosing to merge the work, discard the branch, or continue iterating.

    Frameworks & tools

    This skill works with any git-based project. It automatically detects test configurations in package.json, pyproject.toml, Makefile, and README files to ensure code quality.

    Why this beats prompting it yourself

    Standard prompts often hallucinate paths or accidentally modify your local HEAD when trying to switch branches. This skill enforces strict directory isolation and automated cleanup logic that prevents your primary workspace from becoming inconsistent during complex tasks.

    Use cases

    • Risky refactors where you want to see the impact before committing to the change.
    • Parallel prototyping to compare two different implementation patterns side-by-side.
    • Dependency upgrades to verify breaking changes without breaking your main dev environment.
    • Bug reproduction on a clean branch while keeping your current work-in-progress stashed or active.

    Known limitations

    Requires an initialized git repository. Uncommitted changes in the main directory are not automatically synced to the worktree.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Frequently Asked Questions

    This skill eliminates the risk of a "dirty" workspace by creating physically separate directories for each coding task, allowing you to experiment and run tests without affecting your current local files or HEAD state.

    The skill is compatible with any AI agent that has file system and terminal access. It is language-agnostic and automatically detects test configurations in common files like package.json, pyproject.toml, and Makefiles.

    No, the skill creates an isolated worktree. To maintain total safety, uncommitted changes in your main directory are not synced, ensuring your work-in-progress remains untouched and secure.

    Once a task is complete, the skill provides a detailed impact report; you then have the option to automatically merge the changes into your target branch or delete the worktree to keep your environment clean.

    You receive the full skill logic, including the environment validation, automated testing, and worktree management protocols, along with documentation for integrating it into your preferred AI workflow.

    New in Code Quality & Review

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.

    Free