agentleFS
UsmanBukUsmanBuk/Skills/skills/isolated-worktree-db/SKILL.md

isolated-worktree-db

Skill0 starsChanged 9 days agoMITView on GitHub

Create, run, and safely clean up an isolated Git worktree with its own local database, Docker Compose project, ports, and runtime configuration. Use whenever experimental or parallel development must start from committed main without inheriting another agent's uncommitted changes, especially when the work needs database migrations, seeded/cloned data, a local server, or disposable containers.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. UsmanBuk/skills★ 0100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository11 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 12 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a disposable development environment that cannot modify the primary worktree's uncommitted files or share its database accidentally.

    line 8
  2. Distinctive:

    Read the repository's agent/project instructions before acting.

    line 12
  3. Distinctive:

    Default the base to the committed main HEAD unless the user names another committed ref.

    line 15
  4. Very specific:

    Use a sibling worktree path such as <repo>-<slug> and a branch such as experiment/<slug>.

    line 18
  5. Distinctive:

    Do not force, overwrite, or delete an existing path or branch to make this command succeed.

    line 24
  6. Very specific:

    Use a dedicated database name and dedicated volume or tmpfs.

    line 32
  7. Distinctive:

    Keep the isolation configuration in the experimental worktree.

    line 33
  8. Distinctive:

    Prefer migrations plus project seeds for an empty database.

    line 35
  9. Distinctive:

    When serving the experiment, keep the process identifier in the manifest and use a separate application port.

    line 51
  10. Distinctive:

    Keep the work local unless the user separately asks to commit, push, open a PR, or deploy.

    line 57
  11. Distinctive:

    Stop only the server processes recorded for this worktree.

    line 63
  12. Very specific:

    Run Compose down using the exact worktree Compose file and exact project name.

    line 64
  13. Distinctive:

    Verify that no containers or volumes carrying that Compose project label remain.

    line 65
  14. Very specific:

    Remove the exact absolute worktree path through git worktree remove.

    line 67
  15. Distinctive:

    Keep the experiment branch by default.

    line 69
  16. Distinctive:

    Never use broad recursive deletion, unresolved variables, globs, the repository root, or the home directory as cleanup targets.

    line 71

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Isolated Worktree and Database

Create a disposable development environment that cannot modify the primary worktree's uncommitted files or share its database accidentally. Adapt commands to the repository's existing tooling; isolation guarantees matter more than a particular Compose layout.

Establish the boundary

  1. Read the repository's agent/project instructions before acting.
  2. Resolve the primary worktree, repository common directory, current branch, requested base, and all existing worktrees with read-only Git commands.
  3. Inspect the primary worktree status. Treat every local modification there as belonging to someone else: do not stash, copy, commit, reset, or base the experiment on it.
  4. Default the base to the committed main HEAD unless the user names another committed ref. Resolve and record the exact commit SHA.
  5. Choose unique, explicit identifiers for the worktree path, branch, Compose project, database name, container resources, and host ports. Never reuse the primary environment's identifiers.

Use a sibling worktree path such as <repo>-<slug> and a branch such as experiment/<slug>. Create it from the recorded commit, not from working-tree contents:

git worktree add -b experiment/<slug> /absolute/path/<repo>-<slug> <base-commit>

Do not force, overwrite, or delete an existing path or branch to make this command succeed. Pick a new slug or stop and explain the collision.

Isolate the database

Inspect the project first, then use its native database tooling where possible.

  • Give Docker Compose a unique project name. Avoid fixed container_name values.
  • Bind database and application ports to 127.0.0.1 on confirmed-free host ports.
  • Use a dedicated database name and dedicated volume or tmpfs; never point the experimental app or tests at the primary database.
  • Keep the isolation configuration in the experimental worktree. Do not edit the primary worktree to support the experiment.
  • Reuse local secrets only through an existing ignored environment mechanism. Never copy secrets into tracked files or print them.
  • Prefer migrations plus project seeds for an empty database. If representative local data is required, clone only an authorized local development database with the database's dump/restore tooling. Never infer permission to copy production data.
  • Set both application and test database URLs explicitly. Verify them before migrations, jobs, tests, or servers run.

Create a small untracked .codex-isolation.json manifest in the worktree containing the non-secret identifiers needed for exact cleanup: primary path, worktree path, branch, base commit, Compose file/project, service names, database name, host ports, and any server PID/session identifier. Do not store passwords or full credential-bearing URLs.

Verify before development

Confirm all of the following and report the useful endpoints to the user:

  • the new worktree HEAD equals the recorded base commit;
  • primary uncommitted files do not appear in the new worktree;
  • the dedicated database is healthy and reachable only through its chosen local port;
  • application and test configuration resolve to the dedicated database;
  • the chosen application port is free before starting the server;
  • repository instructions, migrations, and proportionate smoke tests pass.

When serving the experiment, keep the process identifier in the manifest and use a separate application port. Do not stop or replace an unknown process occupying a desired port; select another port.

Work safely

Make experimental edits only inside the new worktree. Before commands that can enqueue jobs or start workers, confirm they cannot consume the primary environment's queue, storage, or database. Disable background workers when they are unnecessary for review.

Keep the work local unless the user separately asks to commit, push, open a PR, or deploy. A request to experiment does not authorize publication.

Clean up exactly

Clean up only when the user asks. Read the manifest and independently verify each target before deletion.

  1. Stop only the server processes recorded for this worktree.
  2. Run Compose down using the exact worktree Compose file and exact project name. Include volumes only when the user has asked to discard the isolated database.
  3. Verify that no containers or volumes carrying that Compose project label remain.
  4. Inspect the experimental worktree status and state clearly if uncommitted work will be irrecoverably discarded. Preserve or commit it only if the user requests that.
  5. Remove the exact absolute worktree path through git worktree remove; use --force only when explicit deletion includes uncommitted experiment files.
  6. Prune stale worktree metadata and verify the primary worktree status is unchanged.
  7. Keep the experiment branch by default. Delete it only when the user explicitly requests branch deletion.

Never use broad recursive deletion, unresolved variables, globs, the repository root, or the home directory as cleanup targets. Finish with a concise inventory of what was removed, what remains (especially the branch), and whether discarded data is recoverable.

Example requests

  • “Try this in another worktree with a separate Docker database, based on committed main.”
  • “Set up an isolated local environment so you do not include the other agent's edits.”
  • “Remove the experiment worktree and its database container when you are done.”

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.