# Branches, pull requests and merging

> A branch is a safe draft copy of your project where your agent builds a new task without touching the live `main` version, and a pull request lets you review the changes and test a private Preview before merging them live.

## Analogy

Think of editing a restaurant's printed menu while guests are dining. You don't cross out dishes on the menus at the tables (`main`); you print a draft copy (`branch`), let the owner taste the new dish (`pull request` + `Preview`), and only swap the menus (`merge`) once approved.

## How it works

In your repo, the main branch is the official line of history: whatever is in `main` is what vercel shows on your live production website. Because real visitors see `main`, your agent never builds half-finished work directly on it.

Instead, at the start of each task in your plan, your agent creates a branch named `feature/<short-name>` (for example, `feature/contact-form`). On that branch, it can make commits, experiment, and fix mistakes without affecting the live site.

When the task works locally, the agent pushes the branch to GitHub and opens a pull-request (`gh pr create`). A pull request is a proposal page on GitHub that shows every changed line, runs automated quality checks (lint, type check, and test suite), and asks Vercel to build a private preview link.

You click the Preview link, try the feature yourself, and decide. Only when you say “publish” or “merge” does your agent run `gh pr merge --squash --delete-branch` to merge the finished work into `main`, clean up the temporary branch, and update Production.

## In your project

You will never have to create branches or pull requests by hand. Your agent creates the `feature/...` branch when starting a task from `tasks/todo.md`, opens the pull request when the task is ready, and shares the Vercel Preview link in the chat so you can click and test it.

## Copy for your agent

```text
Show me which branch we are currently on, whether there is an open pull request, and explain what needs to pass before we merge into main.
```

---
Source: [Agentic Makers](https://agenticmakers.app/en/learn/branches-and-pull-requests) · License: CC BY 4.0
