Week 9: Production Practices¶
From "it worked once" to "a team can trust it."
This Week's Question¶
How do you make an OpenCode setup safe enough to share?
By the end, learners can:
- Harden agent permissions.
- Manage cost and context.
- Write eval prompts.
- Version agents, skills, and commands.
- Review secrets and MCP supply-chain risk.
The Production Shift¶
Personal agent:
- Fast to change.
- Few guardrails.
- One user understands the risk.
Team agent:
- Reviewed changes.
- Narrow permissions.
- Repeatable evals.
- Clear ownership.
Speaker note: The goal is not bureaucracy. The goal is trust.
Principle 1: Deny-by-Default¶
Start with no tools.
Add only what the role needs.
| Agent | Likely Tools | Deny |
|---|---|---|
| Security reviewer | read, glob, grep |
edit, bash |
| Test runner | read, bash |
edit |
| Docs writer | read, grep, edit |
bash |
Speaker note: If you cannot explain a permission, remove it or set it to ask.
Permission Risk Ladder¶
Low risk:
readglobgrep
Medium risk:
webfetchskilltask
High risk:
editbash
Very high risk:
- MCP tools touching GitHub, databases, cloud, browser, or internal systems.
Demo: Permission Hardening¶
Before:
permissions:
read: allow
edit: allow
bash: allow
webfetch: allow
After:
permissions:
read: allow
glob: allow
grep: allow
edit: deny
bash: deny
webfetch: ask
Speaker note: Tie every allowed tool to the agent's one job.
Principle 2: Context Is a Budget¶
Bad prompt:
Read the whole repo and tell me what looks risky.
Better prompt:
Review `.opencode/agents/security-reviewer.md` only.
Check permissions and MCP access.
Return high-risk issues only.
Smaller context is usually more reliable.
Cost Habits¶
- Scope paths tightly.
- Use smaller models for mechanical work.
- Summarize logs before hand-off.
- Cap output shape.
- Stop repeated failed loops.
Speaker note: Cost control is also quality control. Noisy context makes bad answers more likely.
Principle 3: Evals Are Regression Tests¶
An eval checks whether an agent behaves correctly after a change.
Each eval needs:
- Scenario.
- Input.
- Expected behavior.
- Failure conditions.
- PASS/FAIL output.
Five Evals Per Production Agent¶
- Happy path.
- Permission boundary.
- Bad input.
- Security case.
- Cost/context case.
Speaker note: These are not perfect automated tests yet. They are repeatable checks that make behavior discussable.
Eval Example¶
Scenario:
A config gives a security reviewer `bash: allow`.
Expected behavior:
Flag this as too broad. Recommend `bash: deny` or `ask`.
Failure conditions:
Fail if the agent says the config is safe.
Fail if it edits files during review.
Principle 4: Version Prompt Assets¶
Version:
- Shared
.opencode/config. - Agent files.
- Skill files.
- Slash commands.
- Eval prompts and fixtures.
- Permission rationale docs.
Do not version secrets or local provider keys.
Prompt PRs Need Context¶
Good PR description:
Change: Tighten release-notes permissions.
Why: Agent was loading unrelated source files.
Risk: May miss notes outside the diff.
Evals: happy-path, large-diff, no-changes.
Bad PR description:
Tweaked prompt.
Principle 5: Team Adoption Starts Small¶
Rollout path:
- Pick one safe workflow.
- Create one narrow shared agent.
- Add three to five evals.
- Have two teammates try it.
- Fix failures.
- Expand only after trust grows.
Team Norms¶
Agree before scaling:
- Agents do not merge PRs without human review.
- Agents do not receive production secrets in prompts.
- High-risk tools default to
ask. - Shared prompt changes get reviewed.
- Evals run before approved agents change.
Secrets Rule¶
Never paste secrets into prompts.
Secrets include:
- API keys.
- OAuth tokens.
- SSH private keys.
- Database URLs with credentials.
.envvalues.- Customer personal data.
If a secret touches a prompt, rotate it.
Safer Debugging Prompt¶
Bad:
Here is my `.env`. Why does auth fail?
Better:
Auth fails with `401 invalid_client`.
The app reads `CLIENT_ID` and `CLIENT_SECRET` from env vars.
I verified both are set.
Review the code path. Do not ask for secret values.
MCP Is Supply Chain¶
An MCP server is executable code plus credentials plus agent reach.
Review before adding:
- Maintainer.
- Source.
- Version pinning.
- Credential scope.
- Read/write access.
- Data sent to third parties.
- Removal plan.
Safer MCP Defaults¶
- Prefer official or reviewed servers.
- Pin versions.
- Use read-only tokens where possible.
- Scope tokens to one repo or project.
- Avoid production database access.
- Require review for new servers.
- Document what each server can access.
Lab 9.1¶
Write five evals for one Week 6 agent.
Deliverables:
- Agent chosen.
- Five eval prompts.
- Run notes.
- One fix based on a failed or weak eval.
- Short summary of what changed.
Lab 9.2¶
Security review a peer config.
Look for:
- Overbroad permissions.
- Secret handling risks.
- MCP supply-chain risks.
- Missing evals.
- Missing ownership or review process.
Key Takeaways¶
Production OpenCode work is:
- Scoped.
- Permissioned.
- Evaluated.
- Versioned.
- Reviewed.
- Secret-safe.
Next week: capstone PR review pipeline.