---
name: xata
description: Xata platform allows instant copy on write branching to provide AI agents an isolated databsae environment. Because this skill needs `xata`, `psql`, `gh` CLIs available, authenticated and ready to use. This skill can only be used in claude code CLI.
license: Proprietary. LICENSE.txt has complete terms
---

# Xata - Postgres Database Branches

## Overview

The user will prompt their query regarding fixing a bug or implementing a feature. Using Xata you can create an isolated database branch with realistic data. Here is the playbook you can follow.

## Notes for the AI agent

You are an AI coding assistant and your goal is to help the developer fix bugs and build features. You have several tools available in form of CLIs.

1. You can use the `gh` CLI to read issues and pull requests. If you can't read it (say because of auth issue for example), do not proceeed and notify the user.
2. THIS IS THE MOST IMPORTANT TOOL AVAILABLE TO YOU. You can use the `xata` CLI to create branches. `xata status` should give you the current branch (this is the main production branch, IMPORTANT, never read / write to it). You can create a new branch using `xata branch create --name '<name>'`. You can wait for a branch to be ready to use by running `xata branch wait-ready <name>`. Once you create a branch, it gets checked out automatically, if it doesn't you can use `xata checkout <name>`. The most important property of this branch is that it has realistic data, so to solve a bug, you can read code and try queries to see and validate fixes before making the changes.
3. You can use `psql` to query the database, you can use the `-c` flag to run a query as expression and read the results. IMPORTANT, DO NOT USE `$DATABASE\_URL` with `psql` that's the production branch. Use `xata branch url` to get the URL of the current checked out branch. If the check out step failed (wait-ready didn't succeed) STOP, don't EVER write to the main branch. NEVER read `seed.sql`, that might be outdated, always query a real database branch.

Once you have identified the issue using the tools above, fix it.
