Answer: You can define an opencode agent in Markdown using frontmatter (with the Markdown body becoming the agent's system prompt) or in JSONC by defining agents under agents in any OpenCode configuration file. Status: Confirmed Entry: tool/opencode/agents-and-automation/agent-file-formats Revision: 1 Digest: sha256:db22481fcdaaea0a (changes whenever the content changes) Timeline: Created: 2026-11-15T13:52:30Z Last changed: 2026-11-15T13:52:30Z Last verified: 2026-11-20T13:44:13Z Next check: 2026-11-21T13:44:13Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Markdown format | .opencode/agents/explainer.md | [1] | 2026-11-20 Markdown frontmatter fields | Markdown Frontmatter accepts the same fields as an agents configuration entry. | [1] | 2026-11-20 JSONC format | Define agents under agents in any OpenCode configuration file | [1] | 2026-11-20 JSONC schema | https://opencode.ai/config.json | [1] | 2026-11-20 Sources: [1] opencode. "Agents | OpenCode". https://opencode.ai/docs/agents/ Role: primary. Accessed: 2026-11-20T13:44:13Z Quote: "The Markdown body becomes the agent’s system prompt: .opencode/agents/explainer.md" (Supports: Markdown format) Quote: "Markdown Frontmatter accepts the same fields as an agents configuration entry." (Supports: Markdown frontmatter fields) Quote: "JSONC Define agents under agents in any OpenCode configuration file" (Supports: JSONC format) Quote: ""$schema" : "https://opencode.ai/config.json"" (Supports: JSONC schema) Snapshot SHA-256: a4d70968cf4cad31cb27a288ac9341ec6bcbc97acb00c712b5681098e11ab672 (captured 2026-11-13T03:55:26Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-15T13:52:30Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:44:13Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:44:13Z Last attempt: 2026-11-20T13:44:13Z Notes and limitations: Extracted automatically from a single official source (section "Formats"). Related: https://latestn.com/tool/opencode/agents-and-automation/agent-file-locations Where do I save an opencode agent file so it's available globally or per project? https://latestn.com/tool/opencode/agents-and-automation/builtin-agents What built-in agents does opencode include and what are their modes? https://latestn.com/tool/opencode/agents-and-automation/create-skill How do I create a skill in opencode? https://latestn.com/tool/opencode/admin-and-enterprise/set-up-scim-directory-sync How do I set up SCIM directory sync in opencode? https://latestn.com/tool/opencode/admin-and-enterprise/verify-email-domains How do I verify email domains for SSO in opencode? https://latestn.com/tool/opencode/admin-and-enterprise/workspace-roles-ownership What roles exist in an OpenCode Console workspace and how do I transfer ownership? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-15T13:52:30Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/opencode/agents-and-automation/agent-file-formats/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/opencode/agents-and-automation/agent-file-formats POST: https://latestn.com/dispute/tool/opencode/agents-and-automation/agent-file-formats with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/opencode/agents-and-automation/agent-file-formats?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I define an opencode agent in Markdown or JSONC format? Revision 1, last verified 2026-11-20T13:44:13Z. https://latestn.com/tool/opencode/agents-and-automation/agent-file-formats (accessed 2026-11-21T09:57:57Z). @misc{LatestN_tool_opencode_agents_and_automation_agent_file_formats_r1, title = {How do I define an opencode agent in Markdown or JSONC format?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/opencode/agents-and-automation/agent-file-formats}}, note = {Revision 1; digest sha256:db22481fcdaaea0a; last verified 2026-11-20T13:44:13Z; accessed 2026-11-21T09:57:57Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/opencode/agents-and-automation/agent-file-formats