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.

Done with Custom agent· Advanced

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.