#### Cloud Agents

# Best practices

Use these recommendations to get more reliable Cloud Agent runs.

## Set up the environment first

Use [Cloud agent setup](/build/agents-window/cloud-agent/setup) so that Grok Build has its environment configured. Like a human developer, Grok Build does better work if its environment is set up correctly.

## Ensure the agent can access what it needs

Before running a Cloud Agent, verify these prerequisites:

* **Secrets**: Make sure the agent has access to required secrets (API keys, database credentials, etc.) through the [Secrets tab](https://grok.com/dashboard/cloud-agents) in your dashboard. For cloud roles, prefer [OIDC tokens](/build/agents-window/cloud-agent/identity) over long-lived access keys.
* **Egress controls**: If you have [network access](/build/agents-window/cloud-agent/security-network) restrictions enabled, ensure all URLs your local development requires are whitelisted.
* **Local testability**: Your repo should be set up to run well locally without requiring external services that cannot be reached from a VM. If it is hard for a human developer to test locally, it will also be hard for an agent.

## Use skills and agents.md to configure your agent

If the cloud agent has trouble testing its changes, use [skills](/build/agents-window/skills) and agents.md to configure your agent. Commit project skills to the repo, [sync personal skills](/build/agents-window/skills#use-personal-skills-with-cloud-agents) for your own Cloud Agents, or [publish a skill](/build/agents-window/plugins#publish-a-skill-to-your-team) so teammates can install it.

Think of the agent as a smart, but low-context human developer. The best way to make sure it does the right thing is to give it the context it needs to understand what to do.

For example, an `AGENTS.md` in a monorepo can list how to run and debug the most-used services, with a skill per key service that says how to test it and when to use the skill.

The skills contain in-depth details, such as how to debug a specific microservice or how to set up a third-party dependency when needed for testing.

## Use rules to enforce conventions

Cloud Agents can read and follow [Rules](/build/agents-window/rules) at three levels:

* **User rules**: Set in Grok Build Settings, these apply to your sessions across all repositories. Best for rules you only want to apply to you personally.
* **Team rules**: Set in the [Rules, Commands, Hooks dashboard](https://grok.com/dashboard/rules), these apply to all team members across every repository. Best for org-wide conventions.
* **Repo rules**: `.cursor/rules/*.mdc` files committed to the repository, these apply to all agents using that repository. Best for repo/project-specific conventions.

## Give the agent the tools it needs

Agents are often limited by the tools they can reach. Use MCP and custom tools so that the agent has access to the same systems a human developer would.

## Mold the tools to the agent

Build tools the agent is good at using, then iterate on them as you watch how the agent uses them.

For example, a small CLI that starts the codebase's services helps where raw dev commands, such as `package.json` scripts, fail: some models forget arguments, and agents get distracted by noisy build logs that human developers know to ignore.
