Assemble a R coding agent from three basic tools
They wired a Claude agent in R to file and shell helpers, then hardened it with safer path checks and editing functions.
- What they did
- Using R’s ellmer package, they set up a Claude-powered agent around three plain functions: one for reading files, one for saving files, and one for executing shell commands. The model got back simple text from each function, and a brief system instruction nudged it to inspect code before changing it and to run tests after edits. They later expanded the setup with directory listing and search, a guard that blocked access outside the project tree, and a tool for more precise edits.
- How it went
- Even with only the first three tools, the agent could locate a function, open the current test file, add a fresh test, and run the suite. The author still judged it far behind Claude Code, and the shell tool stayed a security risk; deeper safety work was left for another post.
- Tips
- Apply the path guard to every file-related action, not just search. A project-folder limit does not make an unrestricted shell command safe, so treat that tool with care.
Try it yourself with Claude Code
Help me create a simple coding agent in [language] with [LLM provider]. Start with three tools: one that reads a file, one that writes a file, and one that runs a shell command. Use them to complete [task] inside [project folder], and make the agent check the current code before editing and run tests after each change. If the agent needs to do anything irreversible, such as [sending, deleting, submitting, paying, or making changes outside the project], pause and ask me to confirm first. After the first version works, suggest one additional tool at a time that would make it safer or faster, and explain the reason before adding it.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Build a terminal calling tool with human backup
They wired a CLI agent to place calls and loop in a person only when it needed an answer.
Retype the changes an agent made to your feature
They inspect the key edits from an agent-built feature and type them in themselves to better understand the code.
Use an agent to open PRs that speed up CI
A CI agent reviewed workflows and opened PRs that reduced test time and cost, while a human approved each change before merge.
Set up a GitHub bot that triages and patches bugs
They built a GitHub bot that sorts issues, reviews pull requests, answers with citations, and opens patch PRs for humans to check.
Have coding agents test your onboarding flow
Run coding agents through your product’s onboarding and get a scorecard, fix list, and session traces.
Deploy a project and register a domain from one agent flow
A custom agent can set up a Cloudflare account, buy a domain, and ship an app with only brief approval steps.