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
Run coding agents in parallel with tmux and Markdown specs
Manuel Schipper uses separate tmux panes and numbered Markdown specs to keep several coding agents moving at once.
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.
Add simple forgetting to agent memory
A developer added a basic forgetting layer to an agent’s memory and said it worked extremely well right away.
Review Linux kernel patches before they land
Google’s Sashiko scans Linux kernel submissions and flags bugs that human reviewers missed.
Create a CLI coding agent from a Python LLM base
Claude Code turned Simon Willison’s Python LLM template into a working CLI coding agent from two prompts.
Use an agent to inspect and explain COBOL on z/OS
A desktop agent connected to a mainframe to read COBOL, submit jobs, and summarize failures from spool output.