claude_code
Declarative Claude Code configuration. Manage your ~/.claude/settings.json from a Lua table — permissions, environment variables, hooks, and model preferences.
local claude_code = require("rootbeer.claude_code")Example
claude_code.config({
model = "sonnet",
lsp = { "typescript-lsp", "pyright-lsp" },
permissions = {
allow = {
"Bash(npm run *)",
"Bash(cargo *)",
"Edit(*)",
},
deny = {
"Read(.env)",
"Read(.env.*)",
"Bash(curl *)",
},
},
env = {
CLAUDE_CODE_ENABLE_TELEMETRY = "0",
},
})
claude_code.prompt([[
## Conventions
- Use TypeScript with strict mode
- Prefer functional patterns over classes
- Always run tests before committing
- Use conventional commit messages
]], { lsp = true })LSP Support
Claude Code can use Language Server Protocol for semantic code navigation — go-to-definition, find-references, hover types, and real-time diagnostics. This is not enabled by default; it requires an env flag (ENABLE_LSP_TOOL) discovered via anthropics/claude-code#15619.
The lsp field handles all of this for you. Pass a list of plugin names and rootbeer will:
- Set
ENABLE_LSP_TOOL=1in your settings env - Register each plugin as
name@claude-plugins-officialinenabledPlugins
You still need to install both the language server binaries and the Claude Code plugins manually — rootbeer manages the settings, not the installation:
# 1. Install the language server binary
npm i -g pyright
# 2. Update the plugin catalog and install
claude plugin marketplace update claude-plugins-official
claude plugin install pyright-lspAvailable plugins: typescript-lsp, pyright-lsp, gopls-lsp, rust-analyzer-lsp, jdtls-lsp, clangd-lsp, csharp-lsp, php-lsp, kotlin-lsp, swift-lsp, lua-lsp.
claude_code.config({
lsp = { "typescript-lsp", "pyright-lsp", "rust-analyzer-lsp" },
})Pass { lsp = true } to prompt() and rootbeer will automatically append a "Code Intelligence" section to your CLAUDE.md that tells Claude to prefer LSP over grep for definitions, references, and type info:
claude_code.prompt("Your instructions here", { lsp = true })API Reference
config(cfg)
Writes Claude Code settings to cfg.path as JSON.
auto_updates_channel("latest"|"stable")optionalcleanup_period_daysnumberoptionalenabled_pluginstable<string, boolean>optional"name@marketplace" key.envtable<string, string>optionalhookstable<string, any>optionallanguagestringoptionallspstring[]optional{"pyright-lsp", "typescript-lsp"}). Automatically sets ENABLE_LSP_TOOL=1 in env and adds entries to enabledPlugins.modelstringoptional"opus", "sonnet").pathstringoptional"~/.claude/settings.json".permissions(claude_code.Permissions)optionalprompt(content, opts)
Writes the global CLAUDE.md instructions file. This file is loaded by Claude Code at the start of every session and applies across all projects. Use it for personal coding conventions, preferred tools, and project-agnostic guidance. When opts.lsp is true, appends guidance telling Claude to prefer LSP for code navigation.
contentstringopts(claude_code.PromptOpts)?claude_code.Permissions
additional_directoriesstring[]optionalallowstring[]optional"Bash(npm run *)").default_mode("acceptEdits"|"askEdits"|"default"|"plan"|"viewOnly")optionaldenystring[]optional"Read(.env)").claude_code.PromptOpts
lspbooleanoptionalpathstringoptional"~/.claude/CLAUDE.md".