# Code with Gary In a code session, Gary works in a repository on its cloud computer: it reads the code, edits files, and runs your tests in a terminal. Each session gets a branch to itself, and you review the diff before anything is pushed. ## Where Code is Open **Code** in Gary for Mac or on the web. It sits beside your chats and has three parts. - **Projects.** A project is a repository, or a folder, that a Gary works in. - **Sessions.** A session is one conversation about one piece of work, on a branch to itself. - **Panes.** Each session has **Diff**, **Files**, **Terminal**, **Preview**, and **Tasks** beside the conversation. The work runs on Gary's cloud computer, so a session keeps going after you close your laptop. Gary tells you when it finishes or needs an answer. ## Add a project 1. Open **Code** and choose **Add a project**. 2. Pick the Gary whose computer the code runs on. 3. Pick the source. 4. Choose **Add**. | Source | What it is | Push and merge request | | --- | --- | --- | | **GitLab** or **GitHub** | A repository you can reach with your connected account. Gary clones it to its computer. | Yes | | **Folder on this Mac** | A folder on your own computer. The files stay there, and Gary works in them through Gary for Mac or the `gary` tool. | You push from your computer | | **No repository** | A new repository that exists only on Gary's computer. | No. It isn't synced anywhere. | A repository source needs the app connected first. If it isn't, Gary shows **Connect GitLab** or **Connect GitHub**. See [Connect your apps](/connectors). Add only repositories you trust. A repository's own instruction and settings files apply to Gary's sessions in it, as described under "Project instructions" below. ## Start a session 1. Choose the project, then choose **New session**. 2. Say what you want done. Gary creates a working copy of the repository on a branch named `gary/` followed by the session's title and a short id, cut from the default branch. Two sessions never share a working copy. In a session, Gary: - **Reads the code.** It searches the repository and opens the files that matter before it changes anything. - **Edits.** Each change shows in **Diff** as Gary makes it. - **Runs commands.** It installs dependencies, runs the tests, and reads the output. - **Keeps a task list.** **Tasks** shows the steps and which one Gary is on. ::: cards 2 ### Fix a failing test Finds the cause, changes the code, and runs the suite. > The date parser test fails on leap years. Find out why, fix it, and run the whole test suite before you tell me it's done. ### Add an endpoint Follows the patterns already in the repository. > Add a GET endpoint for a customer's invoices, shaped like the orders endpoint. Include tests. Don't change the database schema. ### Explain a module Reads without changing anything. > Walk me through how sign-in works in this service, file by file. Change nothing. ### Upgrade a dependency Makes the change and reports what broke. > Upgrade the HTTP client to the latest major version, fix what breaks, and list every call site you changed. ::: ## Approve commands and edits Each session has a mode. Choose it from **Mode** in the message box. A change applies from Gary's next turn. | Mode | Reading | Edits | Commands | | --- | --- | --- | --- | | **Plan** | Runs | Not made. Gary writes a plan first. | Not run | | **Ask** | Runs | Asks each time | Asks each time | | **Accept edits** | Runs | Made without asking | Asks each time | | **Auto** | Runs | Made without asking | A safety check decides. Gary asks when the check isn't sure. | **Ask** is the mode a new session starts in. When Gary asks, the card shows the command or the file. | Button | What it does | | --- | --- | | **Allow once** | Runs this one call. | | **Allow this command for the session** | Runs it, and runs the same command again without asking until the session ends. | | **Deny** | Doesn't run it. You can add a note, and Gary reads it. | If nobody answers within 30 minutes, Gary takes that as a denial and tells you. In **Plan**, Gary shows its plan as a card. Choose **Approve the plan** to let it start, which moves the session to **Ask**. Choose **Keep planning** and say what to change. ## Review the diff **Diff** shows every changed file against the branch point, with lines added and removed. **Files** shows the working copy. You can open a file, edit it, and choose **Save**. If Gary changed the file since you opened it, nothing is saved, and you choose **Take Gary's version** or **Save mine over it**. To have Gary check its own work, ask for a review. Gary reads the session's changes and lists what it finds: bugs, missed cases, and tests that don't cover the change. ## Commit, push, and open a merge request 1. In **Diff**, enter a commit message and choose **Commit**. 2. Choose **Push**. The branch goes to GitLab or GitHub. 3. Choose **Open draft MR**, and check the title and the description Gary wrote. Gary pushes only to the session's own branch. It can't push to another branch, delete a branch, or move a tag. Your access token never reaches Gary's computer: the push goes through QUANTIS's servers with your connected account. Gary never merges. After the merge request is open, the session shows its state: the pipeline, review comments, and conflicts. If a check fails, choose **Fix failing checks**, and Gary reads the failed job's log and works on it. When it's ready, you choose **Merge**, or merge on GitLab or GitHub yourself. ## Preview a running app **Preview** shows the app Gary is running, in the browser on Gary's computer. Ask Gary to start the app, or add a `.claude/launch.json` file to the repository that names the dev server's command and port. Gary starts the server, opens the page, and looks at it before it says a change works. You can take control of the preview to click through it yourself. A preview is reachable only from Gary's computer. It has no public address. ## Use the terminal Choose **Terminal**, then **Open a shell**. You get a shell on Gary's computer, in the session's working copy, as the same user Gary runs commands as. A Gary can have 3 terminals open at once. A terminal nobody uses for 30 minutes closes. While a terminal is active or a dev server is running, the Gary doesn't rest. ## Project instructions Gary reads the repository's own instructions at the start of every session. - **`CLAUDE.md`** at the top of the repository: how to build and test, conventions, and what to leave alone. Write it the way you'd brief a new teammate. - **`.claude/settings.json`**: permission rules and hooks for the repository. A rule there can allow a command without asking, even in **Ask**. - **Project settings.** Choose **Project settings…** to set the mode new sessions start in. Your instructions for the Gary itself, and what it remembers about you, apply as well. See [See what Gary remembers](/memory). ## Work in a folder on your own computer With **Folder on this Mac**, the session works in the files where they are. Nothing is copied to the cloud. - Gary reads and searches the folder without asking. - A write or a command shows a card, such as "Run `make test` on your Mac?", under the session's mode. - Git runs on your computer, with your own credentials. - The computer has to be on and connected. If it isn't, Gary says so and waits. Share folders in Gary for Mac, or with `gary dir add` on macOS, Linux, or Windows. See [Gary on the command line](/command-line). ## Run several sessions Start as many sessions as you need. Each has its own branch and working copy, so they don't collide. - **Split View** shows two sessions side by side. - **Side chat** opens a chat beside the session for a question that shouldn't interrupt the work. - **Archive** puts a finished session away. Its branch stays on GitLab or GitHub if you pushed it. - **Schedule a task…** runs a prompt in the project on a schedule, as a new session each time. A scheduled session runs only in **Auto**, because nobody is there to answer a card. Sessions share the computer's processor and memory. If builds slow down with several running, see the sizes in [Use Gary's computer and browser](/computer-and-apps). ## Models for code Choose the model for a session from the **Model** menu. The QUANTIS model is included in your plan. Claude, GPT, Gemini, and others draw from your monthly credit, then from extra use. See [Choose a model](/models) and [Usage limits](/usage-limits). A long session fills the model's working memory. Ask Gary to sum up the session so far, and it carries on with the summary. ## Messages | Message | What to do | | --- | --- | | Connect GitLab first | Connect the app in **Connections**, then add the project again. | | This project isn't connected to a repository: nothing is pushed | The project is **No repository** or a folder on your computer. Push from your computer, or add the repository as a project. | | Mark it ready first | The merge request is a draft. Mark it ready on GitLab or GitHub. | | Gary changed this file since you opened it, so nothing was saved. | Choose **Take Gary's version** or **Save mine over it**. | | Auto isn't allowed on this Gary | Use **Accept edits**, or ask your admin to allow **Auto**. | ## On iPhone Code sessions appear in **Tasks** with their state. You can read a session, reply to it, and answer its approval cards and plans. The diff, the terminal, and the preview are in Gary for Mac and on the web.