@@ -962,3 +962,203 @@ $ARGUMENTS
962962
963963---
964964
965+ ## Custom Agent/Command Prompts
966+
967+ These are user-defined agents and commands stored in the ` .opencode/ ` directory. They extend OpenCode's functionality with project-specific behaviors.
968+
969+ ### Agent Structure
970+
971+ Custom agents are Markdown files with YAML frontmatter located in:
972+ - ` .opencode/agent/*.md `
973+ - ` agent/**/*.md ` (nested agents supported)
974+
975+ ** Format:**
976+ ``` markdown
977+ ---
978+ description: When to use this agent
979+ mode: subagent | primary
980+ ---
981+
982+ Agent prompt content goes here...
983+ ```
984+
985+ ### Command Structure
986+
987+ Custom commands are Markdown files with YAML frontmatter located in:
988+ - ` .opencode/command/*.md `
989+ - ` command/**/*.md `
990+
991+ ** Format:**
992+ ``` markdown
993+ ---
994+ description: What this command does
995+ ---
996+
997+ Command template with $1, $2, $ARGUMENTS placeholders
998+ ```
999+
1000+ ### Example Custom Agents
1001+
1002+ #### 1. Git Committer Agent
1003+
1004+ ** File:** ` .opencode/agent/git-committer.md `
1005+
1006+ ** Purpose:** Handles git commit and push operations with specific commit message guidelines.
1007+
1008+ ** Configuration:**
1009+ ``` markdown
1010+ ---
1011+ description: Use this agent when you are asked to commit and push code changes to a git repository.
1012+ mode: subagent
1013+ ---
1014+
1015+ You commit and push to git
1016+
1017+ Commit messages should be brief since they are used to generate release notes.
1018+
1019+ Messages should say WHY the change was made and not WHAT was changed.
1020+ ```
1021+
1022+ ** Key Guidelines:**
1023+ - Brief commit messages for release notes
1024+ - Focus on "why" not "what"
1025+ - Subagent mode (can be called by primary agent)
1026+
1027+ #### 2. Documentation Agent
1028+
1029+ ** File:** ` .opencode/agent/docs.md `
1030+
1031+ ** Purpose:** Specialized agent for writing technical documentation with specific formatting rules.
1032+
1033+ ** Configuration:**
1034+ ``` markdown
1035+ ---
1036+ description: ALWAYS use this when writing docs
1037+ ---
1038+
1039+ You are an expert technical documentation writer
1040+
1041+ You are not verbose
1042+
1043+ The title of the page should be a word or a 2-3 word phrase
1044+
1045+ The description should be one short line, should not start with "The", should
1046+ avoid repeating the title of the page, should be 5-10 words long
1047+
1048+ Chunks of text should not be more than 2 sentences long
1049+
1050+ Each section is separated by a divider of 3 dashes
1051+
1052+ The section titles are short with only the first letter of the word capitalized
1053+
1054+ The section titles are in the imperative mood
1055+
1056+ The section titles should not repeat the term used in the page title, for
1057+ example, if the page title is "Models", avoid using a section title like "Add
1058+ new models". This might be unavoidable in some cases, but try to avoid it.
1059+
1060+ Check out the /packages/web/src/content/docs/docs/index.mdx as an example.
1061+
1062+ For JS or TS code snippets remove trailing semicolons and any trailing commas
1063+ that might not be needed.
1064+
1065+ If you are making a commit prefix the commit message with ` docs: `
1066+ ```
1067+
1068+ ** Key Guidelines:**
1069+ - Not verbose
1070+ - Short titles (1-3 words)
1071+ - Brief descriptions (5-10 words, no "The")
1072+ - Max 2 sentences per paragraph
1073+ - Section dividers: ` --- `
1074+ - Imperative mood for section titles
1075+ - Capitalize only first letter
1076+ - No trailing semicolons/commas in JS/TS snippets
1077+ - Commit prefix: ` docs: `
1078+
1079+ ### Example Custom Commands
1080+
1081+ #### 1. Commit Command
1082+
1083+ ** File:** ` .opencode/command/commit.md `
1084+
1085+ ** Purpose:** Shortcut command for committing and pushing changes.
1086+
1087+ ** Configuration:**
1088+ ``` markdown
1089+ ---
1090+ description: Git commit and push
1091+ ---
1092+
1093+ commit and push
1094+ make sure it includes a prefix like docs:, tui:, core:...
1095+ ```
1096+
1097+ ** Usage:** User can type ` /commit ` to trigger this command template.
1098+
1099+ #### 2. Spellcheck Command
1100+
1101+ ** File:** ` .opencode/command/spellcheck.md `
1102+
1103+ ** Purpose:** Runs spellcheck on specified files or directories.
1104+
1105+ ** Configuration:**
1106+ ``` markdown
1107+ ---
1108+ description: Run spellcheck on files
1109+ ---
1110+
1111+ run spellcheck on $ARGUMENTS
1112+ ```
1113+
1114+ ** Usage:** User can type ` /spellcheck <files> ` and ` $ARGUMENTS ` will be replaced with the specified files.
1115+
1116+ #### 3. Hello Command
1117+
1118+ ** File:** ` .opencode/command/hello.md `
1119+
1120+ ** Purpose:** Simple test command for verification.
1121+
1122+ ** Configuration:**
1123+ ``` markdown
1124+ ---
1125+ description: Say hello
1126+ ---
1127+
1128+ say hello
1129+ ```
1130+
1131+ ** Usage:** User can type ` /hello ` to test custom commands.
1132+
1133+ ### Built-in Agents
1134+
1135+ OpenCode includes three built-in agents defined in ` /packages/opencode/src/agent/agent.ts ` :
1136+
1137+ 1 . ** general** - Research, searching code, multi-step tasks (subagent mode)
1138+ 2 . ** build** - Primary agent for solving tasks (primary mode)
1139+ 3 . ** plan** - Planning and analysis phase (primary mode, read-only permissions)
1140+
1141+ ### Loading Mechanism
1142+
1143+ Agents and commands are loaded from:
1144+ - Local project: ` .opencode/agent/*.md ` , ` .opencode/command/*.md `
1145+ - Nested: ` agent/**/*.md ` , ` command/**/*.md `
1146+ - Built-in agents: Defined in code
1147+
1148+ The YAML frontmatter becomes configuration, and the Markdown content becomes the ` prompt ` field (for agents) or ` template ` field (for commands).
1149+
1150+ ---
1151+
1152+ ## Summary
1153+
1154+ OpenCode uses a sophisticated multi-layered prompting system:
1155+
1156+ 1 . ** System Prompts:** Provider-specific core instructions (14 variants)
1157+ 2 . ** Mode Control:** Plan (read-only) and Build (read-write) enforcement
1158+ 3 . ** Utility Prompts:** Title generation and conversation summarization
1159+ 4 . ** Agent Generation:** Dynamic creation of new custom agents
1160+ 5 . ** Command Templates:** Repository initialization and setup
1161+ 6 . ** Custom Agents/Commands:** User-defined project-specific extensions
1162+
1163+ All prompts work together to create a flexible, powerful AI coding assistant that adapts to different models, modes, and user requirements while maintaining consistent behavior and high code quality.
1164+
0 commit comments