Skip to content

How to Get AI Coding Agents to Follow Your Project Rules with AGENTS.md

With Agentic Mode in Xojo 2026r3, a coding agent can read and edit your project files. Additionally, it can ask Xojo to build and run your app in debug mode. If the build fails, the agent can use the compiler errors to fix the code.

Think of the agent as a developer intern on their first day. Explain what the app does and how you work on it. Give the agent one small task with a clear result, then review its changes and try them in Xojo.

Say you’re working on an inventory app where “low stock” means five units or fewer. Save that rule in AGENTS.md so the agent can use it again. In the agent’s chat, ask for a checkbox that shows only products with low stock.

You can adapt these examples to your own Xojo project. If you need help connecting your coding agent to Xojo, start with the QuickStart. Xojo AI QuickStart

The two files Xojo uses in Agentic Mode

When you enable Agentic Mode, Xojo creates XOJO-CODING.md in the project folder. It contains Xojo’s guidance on working with project files, finding the documentation, and running the project. Each time you open the project in Agentic Mode, Xojo retrieves a fresh copy from its servers so we can keep that guidance up to date. We regularly test different AI models and refine the instructions to help them write correct Xojo code. Xojo Agentic Mode documentation

Do not edit XOJO-CODING.md. Xojo overwrites it the next time you open the project in Agentic Mode. Put your own instructions in AGENTS.md.

If your project folder has no AGENTS.md, Xojo creates a starter whose only job is to point the agent to XOJO-CODING.md. If you already have an AGENTS.md, Xojo keeps it. Open AGENTS.md in a plain-text editor and add your own sections below the existing Xojo reference. If your file is missing that reference, this blog post shows how to add it. 

Give the agent rules it can use again

Think of questions that a new developer would ask you to get started on this project. Which module handles database access? What should they check after changing the import?

Suppose your AGENTS.md starts like this.

# AGENTS.md

@XOJO-CODING.md

Add your own section below the existing XOJO-CODING.md reference. Some projects use a longer block for the reference. Keep that block intact too.

# AGENTS.md

@XOJO-CODING.md

## Inventory app

- Low stock means five units or fewer, including zero.
- Filters only change which rows are visible. Ask before changing how inventory is saved.
- When you change a filter, tell me how to check the cutoff and what happens when no rows match.

You can ask the agent to write a short overview of an existing project. Try asking, “Review the whole project and add a Project overview section to AGENTS.md. Explain what the app does, where its main features live, and any project conventions you can verify. Keep the XOJO-CODING.md reference intact.” Review what it writes and correct anything it misunderstood.

When you find yourself asking for the same test again, save it as a rule. “Add a bullet to AGENTS.md asking future agents to check items with zero, five, and six units when they change the low-stock filter. Keep the XOJO-CODING.md reference intact and show me the new bullet.”

Three sections you can use for AGENTS.md

In one of my projects, I kept @XOJO-CODING.md at the top and added the sections below. Copy whichever sections suit your project.

# AGENTS.md

@XOJO-CODING.md

## Code conventions

- Prefer native Xojo objects unless the task calls for something else.
- Use `Str(expression)` to convert an arithmetic expression to a string.
- Use descriptive variable names. Avoid `text` as a variable name.
- Follow the [Xojo coding guidelines](https://documentation.xojo.com/topics/code_management/coding_guidelines.md) where this project has no convention of its own.

## Analyze the Project

Project > Analyze Project compiles the whole project for the current target but doesn't build or run it. Treat it as the compiler with warnings on. It checks correctness, not style or the coding guidelines.

- **Errors**: anything that would stop the build.
- **Warnings**: whatever the user has enabled in the IDE's Analysis Warnings settings. Usually deprecated APIs that have a replacement, unused locals and parameters, lossy implicit conversions, and `#Pragma Warning` messages.

**When:** after each round of edits, before Build & Run. It's faster and finds the same compile errors. Before finishing, the project must analyze with no errors. Then also Build & Run, as XOJO-CODING.md requires. If running isn't possible, a clean Analyze is the minimum.

**Limits:**

- It checks the current target only. Code in another platform's `#If` branch is skipped and may still have errors. Variables used only there are reported as unused. Don't delete them.
- A missing warning doesn't mean the code is clean, because the user may have that check turned off.
- Ignore warnings from encrypted classes and third-party plugins.

**Run** the command for your OS once. If you get no reply within 5 seconds, don't retry. Ask the user to run Project > Analyze Project and paste the contents of the Errors & Warnings pane.

Windows:

```powershell
$b = [Text.Encoding]::UTF8.GetBytes("{`"protocol`":2}`0" + '{"tag":"t","script":"DoCommand(\"CheckProjectErrors\")\nPrint \"done\""}' + "`0")
$cl = foreach ($p in (Get-NetTCPConnection -OwningProcess (Get-Process Xojo).Id -State Listen).LocalPort) { try { $t = [Net.Sockets.TcpClient]::new('127.0.0.1', $p); $t.GetStream().Write($b, 0, $b.Length); $t } catch {} }
Start-Sleep 5
foreach ($t in $cl) { $s = $t.GetStream(); $r = New-Object byte[] 65536; while ($s.DataAvailable) { [Text.Encoding]::UTF8.GetString($r, 0, $s.Read($r, 0, 65536)).Replace("`0", "`n") }; $t.Close() }
```

macOS/Linux:

```bash
(printf '{"protocol":2}\0'; printf '{"tag":"t","script":"%s"}\0' 'DoCommand(\"CheckProjectErrors\")\nPrint \"done\"'; sleep 4) | nc -U /tmp/XojoIDE | tr '\0' '\n'
```

**Result:**

- If no reply or the reply is `"done"`, the project is clean.
- Otherwise, `buildError.errors` and/or `buildError.warnings` come first, followed by `"done"`. The same items go to `XojoCompileErrors.txt`, and a clean analyze clears that file.
- Fix every error, then analyze again.
- Fix warnings only in code you changed. For a deprecation, use the replacement API the warning names. List any other warnings in your summary instead of fixing them. If a parameter is unused on purpose, add `#Pragma Unused paramName`.

## Runtime Logging (Optional)

- When a bug depends on a value you can only see at runtime, add a temporary `System.DebugLog` call near the relevant code. Prefix the message so it is easy to find and name the value you are logging.
- Run the app in the Xojo debugger and reproduce the problem. If you can’t see the IDE’s Messages panel, ask me to paste the lines with the `[AGENT-XOJO-DBG]` prefix.
- Remove temporary logging before finishing the task.

```xojo
#If DebugBuild Then
  System.DebugLog("[AGENT-XOJO-DBG] " + CurrentMethodName + " quantity=" + Str(quantity))
#EndIf
```

Adapt the coding conventions to your project.
Analyzing and debugging a Xojo project · System.DebugLog · DebugBuild · Str

Different agents follow instructions differently

New coding agents and models come out regularly. Some follow project instructions more reliably than others. Xojo controls the guidance it ships and how the IDE responds. The agent and its model determine how closely they follow that guidance.

When you try a new agent or model, ask it to read AGENTS.md and the referenced XOJO-CODING.md, then explain one project rule in its own words. If it gets the rule wrong, check which folder it’s working in and whether it read both files. After its first task, check that the changes follow the rule.

Save a working version with local Git

A Git repository keeps a history of your project files. A commit records a version you can compare with later changes. The whole history can live on your computer.

When I start a new app, I drag the blank Xojo project folder into my coding agent app. The first thing I ask the agent to do is create a local Git repository and commit the blank project. Then I explain what the app is for and what the first usable version needs to do. That first commit gives me a starting point I can compare with the changes the agent makes.

For an existing app, run it first to make sure it still works. Use its Git repository if it has one. To set up Git for a project for the first time, ask the agent to make the initial commit.

Create a local Git repository for this Xojo project. Include the project source, required resources, and AGENTS.md. Add a .gitignore for files such as *.xojo_uistate and generated builds. Make the initial commit. Keep the repository local.

What to ask your coding agent

Use the names you see in the Xojo Navigator so the agent knows where to look. Tell it whether you want an explanation or an edit.

Understand existing code. “Where does the inventory list get its rows? Show me the window and method to open in the Xojo Navigator.”

Plan a change. “How would you add a low-stock filter that works with the existing search box? Tell me which project items you’d edit and wait for me before changing them.”

Make the change. “Add a ‘Low stock only’ checkbox to the Inventory window and leave it unchecked by default. When it’s checked, show rows that match the current search and the low-stock rule in AGENTS.md. When it’s cleared, show all rows that match the current search. Tell me what you changed and what you tested.”

Investigate a bug. “With ‘Low stock only’ checked and the search box empty, an item with five units disappears. An item with four units still shows up. Find where the cutoff is applied and explain the likely cause before editing.”

Update part of an older project to API 2.0

Before changing an older app, run it in the Xojo version you plan to use and save that working version in Git. Turn on deprecation warnings under Project > Analysis Warnings, then use Project > Analyze Project to find calls with documented replacements. Start with one method or module so you can check that it still behaves the same way after the update. Moving to API 2.0 · Updating older projects

Start with the inventory import method. Identify any deprecated API 1.0 calls and propose replacements from the current Xojo documentation. Preserve the existing import behavior, including what happens when the file is missing or invalid. Tell me how to check each case in Xojo.

Watch the Xojo video on YouTube

Verify the task and ask the agent to commit it

Ask the agent to run the project in Xojo after its edits and report what it could verify. For the inventory checkbox, try items with 0, 5, and 6 units. With the filter on, only the first two should appear when the search field is empty. Type a search that matches one of those items, then try one that matches nothing. Clear the checkbox and check that the six-unit item can show up again when it matches the search. The quantities should stay the same throughout. If the agent can only confirm that the app launched, do these checks in the running app yourself. Xojo Agentic Mode documentation

A bug fix or refactor can take several debug runs. Once the task is complete, confirm that the app runs in debug mode and check the behavior you changed. Review the edits, then ask the agent for one local commit for the whole task.

The app ran successfully in Xojo and the filter checks passed. Make a local Git commit with the message “Add low-stock filter to inventory.” Include only the changes for this task. Give me the commit ID and tell me if any changes are still pending.

If you want to make this a regular part of working with the agent, add a rule to AGENTS.md. For example, “For each completed coding task, confirm the project ran successfully in Xojo and check the relevant behavior. Ask me to do any checks you can’t perform. After I review the changes, make one local commit for the task and report the commit ID.”

Happy coding! P.S.: ask the agent about worktrees 🙂

Gabriel is a digital marketing enthusiast who loves coding with Xojo to create cool software tools for any platform. He is always eager to learn and share new ideas!