Coding agents
Working with agents
Developers are now writing a lot of code with agents. Instead of typing every line by hand, they talk to an agent and have it write the code for them.
In the Foundations course, you learned the core behavior behind agents: give them powerful tools and let them run autonomously in a loop. This course covers strategies to work effectively with coding agents when you're building software.
What's an agent harness?
Grok Build is an AI editor with a built-in coding agent. The agent runs inside what's called a "harness," which is made up of three things:
- Instructions: The system prompt and rules that guide behavior
- Tools: File editing, codebase search, terminal execution, and more
- Model: The agent model you pick for the task
Coding agents help you accomplish tasks based on the goals you give them. Every harness has slightly different behavior based on how it's tuned and the models you use.
Some models are trained to call shell commands more often. Others need more explicit instructions. Grok Build aims to support every frontier model and optimize the harness as much as possible, including the tools they have access to.
Writing effective prompts
Your first entry point into working with agents is the prompt you give them. Consider two different approaches:
See the agent's response
Createdpage.tsx+62
import { SettingsForm } from '@/components/SettingsForm'
import styles from './settings.module.css'
export default function SettingsPage() {
return <main className={styles.container}>...CreatedSettingsForm.tsx+45
import { useState } from 'react'
export function SettingsForm() {
const [formData, setFormData] = useState({
username: '', email: '', theme: 'light'
})src/app/settings/page.tsx. I used a basic form layout with the following fields:SettingsForm component with inline CSS modules and a saveSettings API route.The agent had to guess at everything: what layout you wanted, the components, the styling approach, and more. Sometimes this works, but often you need to be more specific with your intent.
Compare that with a more detailed prompt that references existing patterns in your codebase:
See the agent's response
CreatedSettings.tsx+47
import { FormField, FormToggle, FormSelect } from '@/components/ui/Form'
import { useUserPreferences } from '@/hooks/useUserPreferences'
export default function Settings() {
const { preferences, update } = useUserPreferences()Createdroute.ts+23
// Follows the same pattern as profile/route.ts
export async function PATCH(req: Request) {Profile.tsx with the same page shell and spacingFormField, FormToggle, and FormSelect from your UI libraryuseUserPreferences hook for reading and savingsrc/app/api/user/settings/route.ts following the same auth and validation pattern as profile/route.tsThe second prompt is much better because it gives the agent specific instructions grounded in your codebase: existing files, components, and clear scope. The agent follows your patterns instead of inventing new ones.
The developing features chapter covers planning larger changes across multiple files.
Which approach gives agents the best results?
Managing your context
As you work with an agent, your conversation builds up context: messages, tool calls, file contents, and more. This context is the agent's working memory, and it has limitations.
Be mindful of how much context the agent is using. Start a new conversation when you're switching to a new task, or if you notice the agent making mistakes.
If you're still working on the same feature and the agent has useful context from earlier messages, it's worth continuing the conversation. But if the agent keeps going in circles, start fresh even if you're mid-feature. You can reference the old conversation to allow the agent to read the chat transcript.

See the agent's response
EditedAuthService.ts+12-3
return { accessToken, refreshToken }
// Invalidate the old refresh token before issuing a new one
await this.tokenStore.revoke(oldRefreshToken)
return { accessToken, refreshToken: newRefreshToken }AuthService.ts:refreshTokens() method now revokes the old refresh token before issuing a new onerevoke() call to TokenStore that adds the old token to the blocklistauthenticate.ts will reject it with a 401The latest models are getting good at finding context for you. With codebase search, the agent can pull in relevant files as needed. If you know the exact file, tag it. Otherwise, give the agent a general description and let it find the right files.
Common failure pattern: scope creep
One of the most common mistakes is asking for too large of a change without planning. You might notice the agent making unrelated changes, editing files you didn't want, or losing focus.
If you see this happening, stop and consider whether you could break the task into smaller pieces. If you're planning an ambitious feature, [developing features] covers how to create solid plans and specifications(/build/agents-window/learn/creating-features). Once you have that plan and kick off the first conversation, it's often faster to iterate in smaller follow-up conversations after that.
What's next
You've learned how agent harnesses work, how to think about writing effective prompts, and how to manage your context. The next chapter goes deeper on how agents search through your codebase and help you better understand the code and architecture you're working with.
You've completed this chapter
Next: Understanding your codebaseLast updated: November 23, 2026