|
| 1 | +--- |
| 2 | +title: Provide context to tasks |
| 3 | +description: Supply external context from GitHub issues, pull requests, local files, and web resources to give AI agents the information they need |
| 4 | +sidebar: |
| 5 | + order: 5 |
| 6 | +--- |
| 7 | + |
| 8 | +import StepList from '../../../../components/StepList.svelte'; |
| 9 | +import StepItem from '../../../../components/StepItem.svelte'; |
| 10 | +import { CardGrid, LinkCard } from '@astrojs/starlight/components'; |
| 11 | + |
| 12 | +Context lets you attach external information to a [task](/rover/concepts/task) or [iteration](/rover/guides/iterate-tasks) so the AI agent can reference it while working. Instead of pasting content into the task description, use context to provide requirements from GitHub issues, design specs from pull requests, reference documentation from local files, or API specifications from URLs. |
| 13 | + |
| 14 | +## Supported context sources |
| 15 | + |
| 16 | +Rover resolves context URIs through built-in providers. You can combine multiple sources in a single command. |
| 17 | + |
| 18 | +| URI format | Description | Example | |
| 19 | +|---|---|---| |
| 20 | +| `github:issue/<number>` | GitHub issue from the current repo | `github:issue/15` | |
| 21 | +| `github:pr/<number>` | GitHub PR with diff from the current repo | `github:pr/42` | |
| 22 | +| `github:<owner>/<repo>/issue/<number>` | Cross-repo GitHub issue | `github:acme/api/issue/8` | |
| 23 | +| `github:<owner>/<repo>/pr/<number>` | Cross-repo GitHub PR with diff | `github:acme/api/pr/31` | |
| 24 | +| `file:./<path>` | Local file (relative path) | `file:./docs/spec.md` | |
| 25 | +| `file:///<path>` | Local file (absolute path) | `file:///home/user/notes.md` | |
| 26 | +| `https://<url>` | Remote web resource | `https://example.com/api-spec.yaml` | |
| 27 | + |
| 28 | +:::tip |
| 29 | +GitHub context requires the [GitHub CLI (`gh`)](https://cli.github.com/) to be installed and authenticated. |
| 30 | +::: |
| 31 | + |
| 32 | +## Add context to a task |
| 33 | + |
| 34 | +Pass one or more `--context` flags when creating a task. Each flag accepts a context URI. |
| 35 | + |
| 36 | +<StepList title="Creating a task with context"> |
| 37 | + <StepItem step={1}> |
| 38 | + Create a task with context from a GitHub issue and a local spec file |
| 39 | + |
| 40 | + ```sh |
| 41 | + rover task -c github:issue/15 -c file:./docs/api-spec.md "Implement the new endpoint" |
| 42 | + ``` |
| 43 | + |
| 44 | + Rover fetches the issue content and reads the local file, then provides both to the agent alongside the task description. |
| 45 | + </StepItem> |
| 46 | + <StepItem step={2}> |
| 47 | + You can also provide context from a remote URL |
| 48 | + |
| 49 | + ```sh |
| 50 | + rover task -c https://example.com/openapi.yaml "Generate client SDK from the API spec" |
| 51 | + ``` |
| 52 | + </StepItem> |
| 53 | + <StepItem step={3}> |
| 54 | + Follow the task progress |
| 55 | + |
| 56 | + ```sh |
| 57 | + rover logs -f 1 |
| 58 | + ``` |
| 59 | + </StepItem> |
| 60 | +</StepList> |
| 61 | + |
| 62 | +:::tip |
| 63 | +The `-c` short flag is equivalent to `--context`. You can repeat it as many times as needed to attach multiple sources. |
| 64 | +::: |
| 65 | + |
| 66 | +## Add context to an iteration |
| 67 | + |
| 68 | +Context works the same way on iterations. Pass `--context` flags to `rover iterate` to provide additional information for a follow-up iteration. |
| 69 | + |
| 70 | +<StepList title="Iterating with context"> |
| 71 | + <StepItem step={1}> |
| 72 | + Add a PR as context to guide a refinement iteration |
| 73 | + |
| 74 | + ```sh |
| 75 | + rover iterate 1 "Align the implementation with the reviewed approach" -c github:pr/50 |
| 76 | + ``` |
| 77 | + </StepItem> |
| 78 | + <StepItem step={2}> |
| 79 | + Follow the iteration progress |
| 80 | + |
| 81 | + ```sh |
| 82 | + rover logs -f 1 2 |
| 83 | + ``` |
| 84 | + </StepItem> |
| 85 | +</StepList> |
| 86 | + |
| 87 | +### Context inheritance |
| 88 | + |
| 89 | +Context from previous iterations carries forward automatically. When you add new context to an iteration, it is merged with context from earlier iterations. |
| 90 | + |
| 91 | +You don't need to repeat URIs you've already provided. If you pass a URI that was used in a previous iteration, **Rover re-fetches it to get the latest content**. |
| 92 | + |
| 93 | +## Control comment visibility |
| 94 | + |
| 95 | +When using GitHub issues or PRs as context, comments and reviews are **excluded by default** to prevent prompt-injection from untrusted contributors. |
| 96 | + |
| 97 | +You can selectively include comments from trusted authors: |
| 98 | + |
| 99 | +```sh |
| 100 | +# Trust specific authors |
| 101 | +rover task -c github:issue/15 --context-trust-authors alice,bob "Fix the bug" |
| 102 | + |
| 103 | +# Trust all authors (use with caution) |
| 104 | +rover task -c github:pr/42 --context-trust-all-authors "Review and address PR feedback" |
| 105 | +``` |
| 106 | + |
| 107 | +The same flags work with `rover iterate`: |
| 108 | + |
| 109 | +```sh |
| 110 | +rover iterate 1 "Address remaining review comments" -c github:pr/42 --context-trust-all-authors |
| 111 | +``` |
| 112 | + |
| 113 | +## Best practices |
| 114 | + |
| 115 | +- **Prefer context over copy-paste**: Use context URIs instead of pasting content into the task description. This keeps descriptions focused and lets Rover handle formatting and attribution. |
| 116 | +- **Combine context with clear instructions**: Context provides information; the task description should explain what to do with it. |
| 117 | +- **Scope context narrowly**: Provide only the sources relevant to the task. Too much unrelated context can dilute the agent's focus. |
| 118 | +- **Use GitHub PRs for alignment**: When iterating on a task, referencing a related PR helps the agent understand the desired approach and coding patterns. |
| 119 | +- **Be deliberate with comment trust**: Only enable `--context-trust-all-authors` on repositories where you trust all contributors. For open-source projects with external contributors, prefer `--context-trust-authors` with specific usernames. |
| 120 | + |
| 121 | +## Relevant Concepts |
| 122 | + |
| 123 | +<CardGrid> |
| 124 | + <LinkCard title="Task" href="/rover/concepts/task" description="Learn about Rover tasks and how they work" /> |
| 125 | + <LinkCard title="Workflow" href="/rover/concepts/workflow" description="Discover how workflows guide coding agents" /> |
| 126 | +</CardGrid> |
| 127 | + |
| 128 | +## Related Guides |
| 129 | + |
| 130 | +<CardGrid> |
| 131 | + <LinkCard title="Implement a new feature" href="/rover/guides/assign-tasks" description="Create and assign tasks to AI coding agents" /> |
| 132 | + <LinkCard title="Work on GitHub issues" href="/rover/guides/github-issues" description="Create tasks from GitHub issues and track their relationship" /> |
| 133 | + <LinkCard title="Iterate on tasks" href="/rover/guides/iterate-tasks" description="Refine and improve task implementations" /> |
| 134 | + <LinkCard title="Merge changes from tasks" href="/rover/guides/merge-tasks" description="Integrate completed tasks into your codebase" /> |
| 135 | +</CardGrid> |
0 commit comments