Agentic Coding: A Practical Guide to Commands, Configuration, and Permissions
Agentic coding moves the real challenge from generation quality to control. Using the Claude Code family of tools as a reference, this guide answers six practical questions: how to choose authentication and billing, whether slash commands can serve as a standard, how configuration layers merge, how to write debuggable hooks, exactly what checkpoints can roll back to, and how to enforce permissions in configuration. It also covers memory files, skills, a common-mistakes checklist, and a decision framework for handling version-dependent behavior. Because command names, config keys, and exit-code semantics change across versions, the article emphasizes verifying your version and cross-checking the official documentation rather than treating any list as a fixed standard.
Introduction: The hard part is no longer “can it write” but “can it be controlled”
After agentic coding became part of daily development, the real barrier is not generation quality but controllability. Once task chains get longer—cross-file refactoring, bulk migrations, interface changes, script generation—context pollution, permission overreach, behavior drift, and rollback failures tend to surface together.
Using the Claude Code family of general-purpose agentic coding tools as a reference, this article answers six practical questions one by one: how to choose authentication and billing, whether slash commands can be treated as a standard, how configuration layers merge, how to write hooks that are debuggable, exactly what checkpoints can roll back to, and how permissions land in configuration.
One upfront caveat: the command names, configuration keys, and exit-code semantics discussed here change across versions. First confirm your version with <tool> --version, then cross-check against the official documentation for that version. This article provides a decision framework and runnable patterns, not a fixed cross-version standard.
1. Choosing authentication and billing: three paths and how to verify them
The authentication method determines the token billing entry point and usage attribution, so it should be settled before going to production.
- Pay-as-you-go API keys: billed by usage volume. Usage must be checked separately on the platform side that issued the key; usage pages from different cloud providers do not interoperate, and you cannot assume a unified tracking view exists. Suited to evaluation phases, low-frequency use, or teams that want to observe the real consumption rhythm before committing to a subscription.
- Subscription plans: a fixed periodic fee in exchange for a certain quota, usually more economical for heavy users and easier to manage.
- Enterprise integrations: onboard through organization accounts or identity providers, making it easier to centrally manage permissions, auditing, and cost allocation.
Specific prices, quotas, and whether cache-hit discounts are included change over time and by region. A three-step verification approach is recommended: first, open the official pricing page to confirm the currency, billing unit, and whether there is a minimum spend; second, create a test project in your target region, run a fixed set of tasks, and read the measured token count from the official usage page (usage or /cost); third, multiply the measured values by the official unit price and compare side-by-side with subscription plans before deciding. Don’t budget based on numbers from this article or secondhand write-ups.
Recommendation: use pay-as-you-go during evaluation to verify whether the tool and your codebase fit; switch to a subscription once monthly consumption is predictable and stable; once you enter team collaboration, prioritize organization-level permissions, audit logs, and cost attribution to avoid individual keys scattered across many developers.
2. Can slash commands be a standard? Confirm the version, then check local help
Slash commands are the primary control surface of a session; they determine what the model sees, what it can do, and how it responds, and are far more stable than natural-language prompts. Common commands are listed below, all examples—the actual set is defined by /help output:
/helplists available commands, the first step for newcomers/login,/logoutswitch authentication identity/configview and modify the currently active configuration/clearclear context and start a new task/compactcompress context while keeping key points/rewindroll back to a saved checkpoint within the current session/memoryview or edit memory files/skillslist skills;/skill-nameinvoke one manually/hooksmanage hooks;/agentsview subagent definitions/vim,/terminal-setupeditor mode and terminal integration
Handling version differences: some commands (such as the checkpoint-based /rewind) are only available in newer versions and are often unavailable in CI or non-interactive environments. A common team practice is to keep a docs/agent-commands.md file in the repository, with the first line stating “Applies to version: X.Y.Z”, so newcomers run /help once on their first day for comparison, and differences get written into the documentation rather than passed around by word of mouth.
Usage principles: run /clear at the start of a task to avoid historical noise polluting context; proactively run /compact during long sessions to prevent context bloat from causing behavior drift; confirm a rollback point exists before modifying files; put project conventions into memory files rather than repeating prompts every time.
3. How many layers does configuration have? How user-level and project-level merge
Consistency comes from configuration. A typical three-layer structure:
- User level (
~/.claude/): applies across projects, holds personal preferences—editor mode, personal common hooks, default skills. - Project level (
.claude/at the repository root): versioned with the codebase, shared by the team, holds coding standards, directory conventions, test commands, and prohibited-action lists. - Project local (
.claude/settings.local.json): usually gitignored, holds personal temporary overrides.
.claude/├── settings.json # shared project-level settings├── settings.local.json # personal local overrides (not committed)├── commands/ # custom slash commands└── hooks/ # automation hook scripts
A typical settings.json:
{"model": "sonnet","permissions": {"allow": ["Bash(npm run test:*)", "Bash(git diff:*)", "Edit(src/**)"],"deny": ["Bash(rm -rf:*)", "Read(./.env)"]}}
Precedence rules (merge order, later loads override earlier; check exact key names and order against the version documentation): enterprise managed policy → command-line arguments → project local .local.json → project shared .claude/settings.json → user-level ~/.claude/settings.json. Allow lists usually take the union, while deny lists have the highest precedence—if any layer specifies deny, the action is denied. Teams should commit project-level configuration to guarantee consistent behavior across members and CI; when individuals need an override, write .local.json rather than editing shared files.
4. How to write hooks that are debuggable: input, exit codes, and alerts
Hooks are scripts that run automatically on tool lifecycle events, reinforcing the workflow without relying on manual reminders. Common events: PreToolUse (before a tool call, for permission checks and command allowlists), PostToolUse (after a tool call, for formatting, linting, logging), UserPromptSubmit (injecting extra context when a prompt is submitted), and Stop / SessionStart / SessionEnd (session lifecycle, cleanup and archiving).
Key prerequisite: hook parameters are not obtained through environment variables but through a JSON payload received via stdin. Typical fields (version-dependent, check the official documentation):
{"session_id": "…","hook_event_name": "PreToolUse","tool_name": "Bash","tool_input": { "command": "npm test" },"cwd": "/path/to/repo"}
So variables like $CLAUDE_FILE_PATHS are not universal. For editing tools, the file path should be read from tool_input.file_path in stdin; $CLAUDE_PROJECT_DIR, which can be referenced in configuration, is injected by the tool and points to the project root.
A runnable example—a PostToolUse hook that formats the file just edited:
{"hooks": {"PostToolUse": [{"matcher": "Edit|Write","hooks": [{ "type": "command","command": "$CLAUDE_PROJECT_DIR/.claude/hooks/format.sh" }]}]}}
.claude/hooks/format.sh:
#!/usr/bin/env bashset -euo pipefailinput=$(cat) # hook input comes from stdinpath=$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty')[ -z "$path" ] && { echo "[hook] no file_path in input" >&2; exit 0; }if npx prettier --write "$path" >&2; thenecho "[hook] formatted $path" >&2; exit 0elseecho "[hook] prettier failed: $path" >&2; exit 2fi
Exit code and output conventions (using the Claude Code family as an example, always verify against the version): 0 means success, and stdout is shown in debug/verbose mode; 2 means block, and stderr is fed back to the model as feedback—PreToolUse uses it to reject dangerous commands; other non-zero values are treated as non-blocking errors, with stderr shown to the user. stdout from UserPromptSubmit and SessionStart can be injected as additional context.
Design principles: hooks should be short and fast, not blocking the main flow; failures must produce clear feedback and never silently swallow errors; put permission-related checks in PreToolUse and formatting/linting in PostToolUse so code is compliant the moment it lands; each hook should output at least one line of log tagged with the hook name and configure failure alerts (non-zero exit codes feed into monitoring), otherwise a broken hook goes unnoticed.
5. What to write in memory files: layered loading and team sync
A project memory file (usually CLAUDE.md at the repository root) lets the agent automatically load project context at session start, saving repeated explanations. Recommended contents: project overview and architecture summary; build, test, and formatting commands; directory structure and module responsibilities; coding standards and prohibitions; common pitfalls and debugging entry points.
# Project Memory## Architecture- Frontend: component-based UI, state centralized in store/- Backend: layered architecture, business logic in service/## Common Commands- Build: npm run build | Test: npm test | Format: npm run fmt## Conventions- lint and unit tests must pass before committing- do not modify the generated/ directory (auto-generated)
Three advanced practices. Layered memory: put global standards at the root, local conventions in subdirectories, and the agent loads the nearest relevant context. Team sync: commit memory files to reduce onboarding cost for new members. Incremental maintenance: after each retrospective, add newly discovered pitfalls, accumulating organizational knowledge assets. Note: don’t turn the memory file into an architecture encyclopedia; only include what “the model needs to know every time,” otherwise it competes for context budget.
6. Where can checkpoints roll back to: three boundaries of in-session checkpoints
Checkpointing automatically saves a state snapshot before important operations; when results don’t match expectations, you can roll back with /rewind. Applicable scenarios: errors midway through a large multi-file refactor; version conflicts or behavior changes triggered by dependency upgrades; and experimentation—trying different approaches, rolling back on failure without polluting the main branch.
The boundaries must be clear: first, /rewind can only return to a checkpoint saved within the current session—it does not cross sessions or machines, and checkpoints saved before switching sessions cannot be recovered; second, it undoes operations the agent performed in this session and does not replace Git; third, checkpoints are usually stored in a local session directory, so watch disk usage and clean up periodically.
Correct division of labor: use checkpoints for fast in-session iteration, use Git for formal cross-session version management, and still commit at important milestones.
7. How to put security and permissions into practice: configuration entry points, allowlists, sandboxing, and auditing
Agents can execute commands and modify files, so permission design must be moved up front into the configuration file rather than relying on after-the-fact reminders.
- Configuration entry points:
permissions.deny/allowin the project-shared.claude/settings.json; personal overrides go in.local.json. First use deny to backstop dangerous operations, then allow the minimum necessary. - Allowlist rule examples:
"allow": ["Bash(npm run test:*)", "Bash(git status)", "Edit(src/**)"];"deny": ["Bash(rm -rf:*)", "Bash(curl:*)", "Read(./.env)", "Read(./secrets/**)"]. Rules are written as “command name(argument pattern)”, and:*only matches subcommands—it does not allow the whole command through. - Sandbox boundaries: run in a container or isolated virtual environment, mount the repository as needed (use read-only if writes aren’t needed), restrict egress or allow only necessary domains; don’t inject production credentials into the container.
- Audit log fields: session transcripts are usually written to disk as JSONL, and are recommended to include
timestamp,session_id,hook_event_name,tool_name,tool_input,exit_codeortool_result, andcwd. Before ingesting into a unified logging system, redact token and key fields, and trace bysession_id.
8. How to organize Skills: minimal fields and trigger boundaries
Skills package a set of prompts, scripts, and resources into a nameable, invokable capability unit: it can be triggered manually via /skill-name, and may also be auto-matched by the agent under specific conditions. Suited to three kinds of scenarios—repetitive tasks (generating PR descriptions per team standards), domain workflows (running a complete security audit), and project-specific operations (initializing a local dev environment).
.claude/skills/├── pr-description/SKILL.md├── security-audit/SKILL.md└── init-env/SKILL.md
The minimal frontmatter and structure of SKILL.md:
---name: pr-descriptiondescription: Generate a PR description from the team template; use when the user asks to "write a PR description"allowed-tools: Read, Bash(git diff:*)---## Prerequisites- The current branch has commits and a diff against the trunk exists## Steps1. Read git diff --stat and the change summary2. Apply .github/PULL_REQUEST_TEMPLATE.md3. Output to stdout, do not push directly## Output- A Markdown block with three sections: "Purpose of changes / Impact scope / Verification"
The boundary between manual invocation and auto-matching: the more specific the description, the more accurate the auto-trigger; vague descriptions cause false triggers. A skill that should only be invoked manually should state “use only when the user explicitly requests it” in the description and avoid generic trigger words.
Design points: one skill solves one class of problem; write inputs, outputs, and prerequisites in the file; skills can be chained into longer workflows; put skills under version control to unify the team’s operational patterns.
9. Common mistakes checklist
- Treating one version’s command list as a universal standard, so newcomers copy it and find commands don’t exist.
- Using undefined environment variables as hook parameters, so hooks silently fail and no one notices.
- Expecting
/rewindto recover across sessions, then losing work. - Writing principles like “deny dangerous operations by default” without concrete rules, so nothing is actually blocked.
- Turning the memory file into an architecture encyclopedia, which competes for context budget.
Conclusion
The competitiveness of agentic coding lies not in how impressive a single generation is, but in whether you can shape it into a stable, controllable, and reusable engineering capability: authentication and billing determine the onboarding posture, slash commands provide a session control surface, layered configuration guarantees cross-project consistency, hooks embed workflow automation into the toolchain, memory persists project knowledge, checkpointing backstops in-session iteration, and skills turn repetitive work into assets. Combine these into a system, and the agent is no longer just a “code completion tool” but a first-class citizen in the development process—programmable, auditable, and evolvable.
