8  Coding with AI

AI tools for coding have matured rapidly, covering a spectrum from simple inline completions to fully autonomous agents that can read, write, and execute code across an entire project. This chapter provides a brief orientation to the tools most relevant to data scientists working in Positron.

It covers the tools only. What your agency permits, which data may go where, who reviews an AI-assisted analysis before it informs a decision, and what you have to record so the result can be defended later are all covered in Chapter 26. Read that chapter before pointing any of these tools at agency data.

8.1 Code Completion with GitHub Copilot

GitHub Copilot is a code completion service that suggests code as you type. Install the GitHub Copilot extension in Positron, and suggestions will appear inline in the editor and in notebooks. Press Tab to accept a suggestion or Escape to dismiss it.

Copilot draws on the surrounding code and comments to infer what you’re trying to write. It works well for boilerplate, common patterns, and filling in function arguments you’d otherwise have to look up.

A GitHub Copilot subscription is required; a free tier is available for individual developers.

8.2 Posit Assistant

Posit Assistant is the default AI experience in Positron beginning with version 2026.07. It can use files and session context, including loaded data, plots, and console history, to help write and run analysis code. The context available to it depends on the connected session, tools, and permissions.

Start with a specific task and inspect the proposed changes. For a larger change, use /plan to work through the approach before implementation. Review tool permissions before allowing commands or access to external services. The current documentation describes planning, permissions, and project instructions.

To connect an approved model provider, open the Command Palette and run Authentication: Configure Language Model Providers. Authentication depends on the provider: some use an API key, others use browser sign-in or cloud credentials. Posit AI Pass is Posit’s hosted service. Consult the provider setup guide for the account and authentication requirements.

Data handling also depends on that connection. With a third-party provider, prompts and selected context may be sent to that provider; with Posit AI Pass, Posit’s service terms apply. Review Posit’s privacy and terms guidance and the specific provider agreement. Do not infer privacy guarantees from the editor’s name.

8.2.1 Older Positron Assistant and Databot instructions

Posit Assistant replaced both Positron Assistant and Databot in Positron 2026.07. Older tutorials describing Ask/Edit/Agent modes or a separate Databot installation apply to earlier releases. Use the current setup guide for new installations. The archived Databot page identifies the transition.

8.3 Claude Code

Claude Code is a terminal-based AI coding agent from Anthropic. Claude Code operates directly in a shell session with access governed by its permissions and configuration: it can read and write files, search the codebase, run commands, and coordinate changes across many files in a single session.

Install it (instructions below for MacOS, Linux, WSL, see docs for Windows).

curl -fsSL https://claude.ai/install.sh | bash

Then launch it from Positron’s integrated terminal (Terminal > New Terminal):

claude

Claude Code is particularly effective for multi-file refactors, complex debugging sessions, and tasks that are tedious to coordinate manually. It is also well suited to translating and explaining legacy SAS programs, a workflow covered in Section 19.4.

8.4 Cost, Privacy, and Model Choice

8.4.1 Capability

Frontier models from OpenAI and Anthropic are substantially more capable than open-weight alternatives for complex reasoning and coding tasks. For most everyday coding work (fixing errors, writing functions, refactoring) a mid-tier model like Anthropic’s Claude Sonnet is fast, inexpensive, and more than capable enough. Save the most powerful (and expensive) frontier models for genuinely hard problems.

Evaluate models on representative tasks: explaining an error, changing a function, or revising a report. Check correctness, the amount of review required, and response time. Model quality changes with releases and differs across tasks. Section 26.5 covers deployment decisions.

8.4.2 Cost

Compare the account’s subscription, included usage, and overage rules. API services commonly meter input and output tokens; a token is a unit of text, not a fixed number of words. Agent sessions can make many calls and repeatedly send context. Measure a few realistic sessions before estimating a monthly budget, and set spending alerts where available.

8.4.3 Privacy

A common concern is whether proprietary code sent to a cloud AI service will be used to train future models. The short answer is: not if you’re paying for API access.

OpenAI and Anthropic state that they do not use API inputs and outputs for model training by default. Opt-in sharing, feedback, retention, and product-specific terms require separate attention. Confirm which account and service the assistant uses; a paid consumer subscription is not the same as API access.

Note

Open-weight models (such as Meta’s Llama or Google’s Gemma) can be run entirely on local hardware, which can support data-residency requirements if the entire deployment, including logs and connected tools, is configured accordingly. Self-hosting requires hardware and staff support; test the chosen model on the work it will actually perform. Evaluate the specific service, agreement, data, and configuration under your agency’s policy (Chapter 26).