Sub topic 2
Project Instructions and Safe Agent Workflows
Assume you can use a shell, Git, and a project's test commands. A terminal coding agent reads project files, calls tools, observes results, and repeats that loop until it reaches a goal. Project instructions make that loop consistent.
Project instructions
Place shared conventions in AGENTS.md. Claude Code also reads CLAUDE.md. Include commands, style rules, test expectations, and files the agent must not edit.
# Project instructions
## Commands
- Install: `npm ci`
- Test: `npm test`
- Lint: `npm run lint`
## Conventions
- Use TypeScript strict mode.
- Add a test for every behavior change.
- Do not edit `dist/` or `generated/`.Keep instructions specific and short. They guide the agent, but they do not replace code review or permissions.
Session controls and permissions
Slash commands control an interactive session. Use the tool's /help command to see its supported commands. Common controls include inspecting status, clearing or compacting context, and ending the session. Command names differ between Claude Code, Codex CLI, and Copilot CLI.
Permissions decide which actions require approval. A read-only investigation can use stricter limits than a task that edits source files. Claude Code settings can allow test commands while denying access to secrets:
{
"permissions": {
"allow": ["Bash(npm run test:*)"],
"deny": ["Read(./.env)"]
}
}Sandboxing limits the files and commands an agent can touch. Codex CLI, for example, can require approval and restrict writes to the workspace:
approval_policy = "on-request"
sandbox_mode = "workspace-write"| Control | Main question | Safer default |
|---|---|---|
| Approval | Must a person approve this action? | Ask before writes or network access |
| Sandbox | Where can the agent write? | The current workspace only |
| Instruction file | Which project rules apply? | Version-controlled, reviewed rules |
Configuration and workflow
Configuration files store permissions, sandbox settings, and other tool-specific preferences. Keep them reviewable and avoid putting credentials in them.
Use a repeatable workflow:
- Ask the agent to inspect the relevant files and propose a plan.
- Review the plan, then request a narrow implementation.
- Run tests, linting, and the build yourself or through approved commands.
- Inspect
git diffand reject unrelated changes. - Commit only the changes you understand.
flowchart TD
A[Inspect repository] --> B[Propose plan]
B --> C[Implement narrow change]
C --> D[Run tests and lint]
D --> E[Review git diff]
E --> F[Commit accepted changes]Exercise
Why should a test command be allowed while arbitrary shell commands remain subject to approval?
Show answer
A narrowly allowed test command reduces repeated prompts while limiting the agent's ability to perform unrelated or risky actions.