<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Huynh Gia Buu]]></title><description><![CDATA[Developer]]></description><link>https://heyhuynhgiabuu.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!K-rp!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac0e9790-dbc0-456c-b379-b84fecd05656_400x400.png</url><title>Huynh Gia Buu</title><link>https://heyhuynhgiabuu.substack.com</link></image><generator>Substack</generator><lastBuildDate>Sun, 31 May 2026 04:56:42 GMT</lastBuildDate><atom:link href="https://heyhuynhgiabuu.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Huynh Gia Buu]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[heyhuynhgiabuu@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[heyhuynhgiabuu@substack.com]]></itunes:email><itunes:name><![CDATA[Huynh Gia Buu]]></itunes:name></itunes:owner><itunes:author><![CDATA[Huynh Gia Buu]]></itunes:author><googleplay:owner><![CDATA[heyhuynhgiabuu@substack.com]]></googleplay:owner><googleplay:email><![CDATA[heyhuynhgiabuu@substack.com]]></googleplay:email><googleplay:author><![CDATA[Huynh Gia Buu]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Opencode agents: AI assistant cho từng công việc ]]></title><description><![CDATA[T&#7915; 1 AI chung &#8594; nhi&#7873;u AI chuy&#234;n bi&#7879;t]]></description><link>https://heyhuynhgiabuu.substack.com/p/opencode-agents-ai-assistant-cho</link><guid isPermaLink="false">https://heyhuynhgiabuu.substack.com/p/opencode-agents-ai-assistant-cho</guid><dc:creator><![CDATA[Huynh Gia Buu]]></dc:creator><pubDate>Wed, 26 Nov 2025 09:32:56 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/12eeeeaf-bf10-4989-95c8-dbb713a82125_3292x1926.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>T&#244;i &#273;&#227; t&#7915;ng &#273;&#7875; AI l&#224;m qu&#225; nhi&#7873;u vi&#7879;c c&#249;ng l&#250;c</h2><p>M&#7897;t ng&#224;y n&#7885;, t&#244;i h&#7887;i AI: &#8220;Review code n&#224;y, &#273;&#7891;ng th&#7901;i fix bugs v&#224; vi&#7871;t documentation.&#8221;</p><p>K&#7871;t qu&#7843;? Code &#273;&#432;&#7907;c s&#7917;a nh&#432;ng sai logic ban &#273;&#7847;u. Documentation vi&#7871;t lung tung. Review th&#236;...kh&#244;ng c&#243; review.</p><p>AI &#273;&#227; c&#7889; g&#7855;ng l&#224;m 3 vi&#7879;c c&#249;ng l&#250;c, v&#224; th&#7845;t b&#7841;i &#7903; c&#7843; 3.</p><p>&#272;&#243; l&#224; l&#250;c t&#244;i h&#7885;c &#273;&#432;&#7907;c b&#224;i h&#7885;c quan tr&#7885;ng nh&#7845;t v&#7873; AI: **&#8221;One AI, one job.&#8221;**</p><p>H&#244;m nay t&#244;i s&#7869; ch&#7881; b&#7841;n c&#225;ch t&#7841;o nhi&#7873;u AI assistants chuy&#234;n bi&#7879;t v&#7899;i OpenCode Agents - m&#7895;i &#8220;nh&#226;n vi&#234;n AI&#8221; ch&#7881; l&#224;m &#273;&#250;ng m&#7897;t vi&#7879;c, v&#224; l&#224;m xu&#7845;t s&#7855;c vi&#7879;c &#273;&#243;.</p><div><hr></div><h2>Agents l&#224; g&#236; trong OpenCode?</h2><p>Agents l&#224; <strong>specialized AI assistants</strong> &#273;&#432;&#7907;c configure cho specific tasks v&#224; workflows. M&#7895;i agent c&#243; th&#7875; c&#243;:</p><p>- <strong>Custom prompts</strong> ri&#234;ng cho task c&#7909; th&#7875;</p><p>- <strong>Specific models</strong> ph&#249; h&#7907;p v&#7899;i c&#244;ng vi&#7879;c</p><p>- <strong>Tool access</strong> &#273;&#432;&#7907;c gi&#7899;i h&#7841;n theo nhu c&#7847;u</p><p>- <strong>Permissions</strong> ki&#7875;m so&#225;t nh&#7919;ng g&#236; agent &#273;&#432;&#7907;c l&#224;m</p><p><strong>V&#237; d&#7909; th&#7921;c t&#7871;:</strong></p><p>| Agent        | Purpose          | Tools         | Best for                |</p><p>| ------------ | ---------------- | ------------- | ----------------------- |</p><p>| **Build**    | Full development | All enabled   | Writing code, debugging |</p><p>| **Plan**     | Analysis only    | Read-only     | Review, planning        |</p><p>| **Reviewer** | Code review      | No edit/write | Quality assurance       |</p><p>| **Docs**     | Documentation    | File ops only | Writing docs            |</p><div><hr></div><h2>Hai lo&#7841;i Agents: Primary vs Subagents</h2><h4>Primary Agents</h4><p><strong>Main assistants</strong> b&#7841;n interact tr&#7921;c ti&#7871;p. D&#249;ng <strong>Tab</strong> key &#273;&#7875; switch gi&#7919;a c&#225;c primary agents.</p><p>OpenCode c&#243; <strong>2 built-in primary agents</strong>:</p><p><strong>1. Build (Default)</strong></p><p>- Mode: <code>primary</code></p><p>- All tools enabled</p><p>- D&#249;ng cho development work v&#7899;i full access</p><p><strong>2. Plan</strong></p><p>- Mode: <code>primary</code></p><p>- Restricted permissions (ask before edit/bash)</p><p>- D&#249;ng &#273;&#7875; analyze code, suggest changes m&#224; kh&#244;ng modify codebase</p><blockquote><p><strong>Pro tip:</strong> D&#249;ng Tab &#273;&#7875; switch: Build (write code) &#8594; Plan (review) &#8594; Build (fix)</p></blockquote><h4>Subagents</h4><p><strong>Specialized assistants</strong> &#273;&#432;&#7907;c primary agents invoke cho specific tasks. B&#7841;n c&#361;ng c&#243; th&#7875; <strong>@ mention</strong> manual:</p><pre><code>@general help me search for this function</code></pre><p>OpenCode c&#243; <strong>1 built-in subagent</strong>:</p><p><strong>General</strong></p><p>- Mode: <code>subagent</code></p><p>- Research, search code, execute multi-step tasks</p><p>- D&#249;ng khi search keywords/files v&#224; kh&#244;ng confident t&#236;m &#273;&#250;ng trong first few tries</p><div><hr></div><h2>C&#225;ch s&#7917; d&#7909;ng Agents</h2><h4>1. Switch Primary Agents</h4><pre><code># D&#249;ng Tab key &#273;&#7875; cycle qua primary agents

Build &#8594; Plan &#8594; Build &#8594; ...</code></pre><h4>2. Invoke Subagents</h4><p><strong>Automatically</strong>: Primary agents t&#7921; invoke subagents d&#7921;a tr&#234;n descriptions.</p><p><strong>Manually:</strong> @ mention trong message:</p><pre><code>@general search for authentication functions

@security-auditor check this API endpoint

@docs-writer create README for this module</code></pre><h4>3. Navigate Sessions</h4><p>Khi subagents create child sessions, navigate v&#7899;i keybinds:</p><p>- <code>&lt;Leader&gt;+Right</code>: Cycle forward (parent &#8594; child1 &#8594; child2 &#8594; parent)</p><p>- <code>&lt;Leader&gt;+Left</code>: Cycle backward</p><div><hr></div><h2>Configure Agents: JSON v&#224; Markdown</h2><h4>C&#225;ch 1: JSON trong opencode.json</h4><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;agent&#8221;: {

    &#8220;build&#8221;: {

      &#8220;mode&#8221;: &#8220;primary&#8221;,

      &#8220;model&#8221;: &#8220;anthropic/claude-sonnet-4-20250514&#8221;,

      &#8220;prompt&#8221;: &#8220;{file:./prompts/build.txt}&#8221;,

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: true,

        &#8220;edit&#8221;: true,

        &#8220;bash&#8221;: true

      }

    },

    &#8220;plan&#8221;: {

      &#8220;mode&#8221;: &#8220;primary&#8221;,

      &#8220;model&#8221;: &#8220;anthropic/claude-haiku-4-20250514&#8221;,

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: false,

        &#8220;edit&#8221;: false,

        &#8220;bash&#8221;: false

      }

    },

    &#8220;code-reviewer&#8221;: {

      &#8220;description&#8221;: &#8220;Reviews code for best practices and potential issues&#8221;,

      &#8220;mode&#8221;: &#8220;subagent&#8221;,

      &#8220;model&#8221;: &#8220;anthropic/claude-sonnet-4-20250514&#8221;,

      &#8220;prompt&#8221;: &#8220;You are a code reviewer. Focus on security, performance, and maintainability.&#8221;,

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: false,

        &#8220;edit&#8221;: false

      }

    }

  }

}</code></pre><h4>C&#225;ch 2: Markdown Files</h4><p><strong>Locations:</strong></p><p>- Global: <code>~/.config/opencode/agent/</code></p><p>- Per-project: <code>.opencode/agent/</code></p><p><strong>File name = Agent name</strong> (review.md &#8594; <code>@review</code> agent)</p><p><strong>Example:</strong> <code>~/.config/opencode/agent/review.md</code></p><pre><code>---

description: Reviews code for quality and best practices

mode: subagent

model: anthropic/claude-sonnet-4-20250514

temperature: 0.1

tools:

  write: false

  edit: false

  bash: false

---

You are in code review mode. Focus on:

- Code quality and best practices

- Potential bugs and edge cases

- Performance implications

- Security considerations

Provide constructive feedback without making direct changes.</code></pre><div><hr></div><h2>Agent Options Chi Ti&#7871;t</h2><h4>1. Description (Required)</h4><p><strong>M&#244; t&#7843; agent</strong> - d&#249;ng &#273;&#7875; invoke automatically v&#224; hi&#7875;n th&#7883; trong UI:</p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;review&#8221;: {

      &#8220;description&#8221;: &#8220;Reviews code for best practices and potential issues&#8221;

    }

  }

}</code></pre><h4>2. Temperature</h4><p><strong>Control creativity</strong> c&#7911;a responses:</p><p>| Range       | Use Case                                                        |</p><p>| ----------- | --------------------------------------------------------------- |</p><p>| **0.0-0.2** | Very focused, deterministic - ideal cho code analysis, planning |</p><p>| **0.3-0.5** | Balanced - good cho general development                         |</p><p>| **0.6-1.0** | Creative, varied - useful cho brainstorming                     |</p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;analyze&#8221;: {

      &#8220;temperature&#8221;: 0.1

    },

    &#8220;brainstorm&#8221;: {

      &#8220;temperature&#8221;: 0.7

    }

  }

}</code></pre><h4>3. Model</h4><p><strong>Override default model</strong> cho specific tasks:</p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;plan&#8221;: {

      &#8220;model&#8221;: &#8220;anthropic/claude-haiku-4-20250514&#8221;

    },

    &#8220;complex-analysis&#8221;: {

      &#8220;model&#8221;: &#8220;anthropic/claude-sonnet-4-20250514&#8221;

    }

  }

}</code></pre><blockquote><p><strong>Pro tip:</strong> Faster models cho planning, capable models cho implementation.</p></blockquote><h4>4. Tools</h4><p><strong>Control available tools</strong>:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;tools&#8221;: {

    &#8220;write&#8221;: true,

    &#8220;bash&#8221;: true

  },

  &#8220;agent&#8221;: {

    &#8220;plan&#8221;: {

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: false,

        &#8220;bash&#8221;: false

      }

    }

  }

}</code></pre><blockquote><p><strong>Agent config overrides global config!</strong></p></blockquote><p><strong>Wildcards for MCP tools:</strong></p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;readonly&#8221;: {

      &#8220;tools&#8221;: {

        &#8220;mymcp_*&#8221;: false,

        &#8220;write&#8221;: false,

        &#8220;edit&#8221;: false

      }

    }

  }

}</code></pre><h4>5. Permissions</h4><p><strong>Fine-grained control</strong> - <code>&#8221;ask&#8221;</code>, <code>&#8221;allow&#8221;</code>, ho&#7863;c <code>&#8221;deny&#8221;</code>:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;permission&#8221;: {

    &#8220;edit&#8221;: &#8220;deny&#8221;

  },

  &#8220;agent&#8221;: {

    &#8220;build&#8221;: {

      &#8220;permission&#8221;: {

        &#8220;edit&#8221;: &#8220;ask&#8221;

      }

    }

  }

}</code></pre><p><strong>Permissions cho specific bash commands:</strong></p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;build&#8221;: {

      &#8220;permission&#8221;: {

        &#8220;bash&#8221;: {

          &#8220;git push&#8221;: &#8220;ask&#8221;,

          &#8220;git status&#8221;: &#8220;allow&#8221;,

          &#8220;*&#8221;: &#8220;ask&#8221;

        }

      }

    }

  }

}</code></pre><p><strong>Markdown agents v&#7899;i permissions:</strong></p><pre><code>---

description: Code review without edits

mode: subagent

permission:

  edit: deny

  bash:

    &#8220;git diff&#8221;: allow

    &#8220;git log*&#8221;: allow

    &#8220;*&#8221;: ask

  webfetch: deny

---

Only analyze code and suggest changes.</code></pre><h4>6. Mode</h4><p>| Mode       | Description                        |</p><p>| ---------- | ---------------------------------- |</p><p>| `primary`  | Main agent, switchable v&#7899;i Tab     |</p><p>| `subagent` | Specialized, invoked via @ mention |</p><p>| `all`      | Both (default)                     |</p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;review&#8221;: {

      &#8220;mode&#8221;: &#8220;subagent&#8221;

    }

  }

}</code></pre><h4>7. Additional Provider Options</h4><p><strong>Pass-through</strong> provider-specific parameters:</p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;deep-thinker&#8221;: {

      &#8220;description&#8221;: &#8220;Agent with high reasoning effort&#8221;,

      &#8220;model&#8221;: &#8220;openai/gpt-5&#8221;,

      &#8220;reasoningEffort&#8221;: &#8220;high&#8221;,

      &#8220;textVerbosity&#8221;: &#8220;low&#8221;

    }

  }

}</code></pre><div><hr></div><h3>Create Agents: Interactive Command</h3><p><strong>Quick start:</strong></p><pre><code>opencode agent create</code></pre><p><strong>Interactive process:</strong></p><p>1. Choose save location (global/project-specific)</p><p>2. Enter description</p><p>3. Generate system prompt and identifier</p><p>4. Select available tools</p><p>5. Create markdown file</p><div><hr></div><h2>Example Agents t&#7915; Official Docs</h2><h4>Documentation Agent</h4><p><code>~/.config/opencode/agent/docs-writer.md</code>:</p><pre><code>---

description: Writes and maintains project documentation

mode: subagent

tools:

  bash: false

---

You are a technical writer. Create clear, comprehensive documentation.

Focus on:

- Clear explanations

- Proper structure

- Code examples

- User-friendly language</code></pre><h4>Security Auditor</h4><p><code>~/.config/opencode/agent/security-auditor.md</code>:</p><pre><code>---

description: Performs security audits and identifies vulnerabilities

mode: subagent

tools:

  write: false

  edit: false

---

You are a security expert. Focus on identifying potential security issues.

Look for:

- Input validation vulnerabilities

- Authentication and authorization flaws

- Data exposure risks

- Dependency vulnerabilities

- Configuration security issues</code></pre><div><hr></div><h2>Real-world Agent Workflows</h2><h4>Workflow 1: Feature Development</h4><pre><code>1. Plan (Tab): Analyze requirements v&#224; suggest approach

2. Build (Tab): Implement the feature

3. @reviewer: Review code before commit

4. @docs-writer: Update documentation</code></pre><h4>Workflow 2: Bug Fixing</h4><pre><code>1. Plan: Investigate v&#224; identify root cause

2. Build: Implement the fix

3. @reviewer: Final review

4. Commit!</code></pre><h4>Workflow 3: Code Review Process</h4><pre><code>1. @reviewer: Initial code review

2. @security-auditor: Security check

3. Build: Address feedback

4. @reviewer: Re-review

5. Merge!

</code></pre><div><hr></div><h2>Best Practices cho Agents</h2><h4>1. One Agent, One Job</h4><blockquote><p><strong>Good:</strong></p></blockquote><pre><code>---

description: Reviews code for security vulnerabilities

---

Focus ONLY on security issues...</code></pre><blockquote><p><strong>Bad:</strong></p></blockquote><pre><code>---

description: Reviews code, fixes bugs, and writes docs

---

Do everything at once... # Don&#8217;t do this!</code></pre><h4>2. Clear, Specific Prompts</h4><blockquote><p><strong>Good:</strong></p></blockquote><pre><code>## Output Format

For each issue:

- Location: file:line

- Severity: Critical/Major/Minor

- Issue: Description

- Fix: Suggestion</code></pre><blockquote><p><strong>Bad:</strong></p></blockquote><pre><code>Review the code and tell me what&#8217;s wrong.</code></pre><h4>3. Right Model for the Job</h4><p>| Task               | Recommended Model   |</p><p>| ------------------ | ------------------- |</p><p>| Planning, Analysis | Haiku (fast, cheap) |</p><p>| Code Generation    | Sonnet (balanced)   |</p><p>| Complex Reasoning  | Opus (powerful)     |</p><p>| Quick Questions    | Haiku               |</p><h4>4. Minimal Tool Access</h4><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;reviewer&#8221;: {

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: false,

        &#8220;edit&#8221;: false,

        &#8220;bash&#8221;: false

      }

    }

  }

}</code></pre><blockquote><p><strong>Principle</strong>: Only enable tools the agent actually needs.</p></blockquote><h4>5. Temperature Tuning</h4><p>| Use Case        | Temperature |</p><p>| --------------- | ----------- |</p><p>| Code analysis   | 0.1         |</p><p>| Code generation | 0.3         |</p><p>| Documentation   | 0.4         |</p><p>| Brainstorming   | 0.7         |</p><div><hr></div><h2>Troubleshooting Common Issues</h2><h4>Issue 1: Agent Not Found</h4><p><strong>Check file location:</strong></p><pre><code># Global agents

ls ~/.config/opencode/agent/

# Project agents

ls .opencode/agent/</code></pre><blockquote><p><strong>Check file extension:</strong> Must be <code>.md</code></p></blockquote><h4>Issue 2: Agent Not Responding Correctly</h4><p><strong>Check description</strong> - primary agents invoke subagents based on descriptions:</p><pre><code>---

description: Reviews code for SECURITY vulnerabilities # Be specific!

---</code></pre><h4>Issue 3: Wrong Model Used</h4><p><strong>Verify model name:</strong></p><pre><code>opencode models  # List available models</code></pre><p><strong>Check model config:</strong></p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;myagent&#8221;: {

      &#8220;model&#8221;: &#8220;anthropic/claude-sonnet-4-20250514&#8221;  # Exact name

    }

  }

}</code></pre><h4>Issue 4: Tools Not Working</h4><p><strong>Check tools config:</strong></p><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;writer&#8221;: {

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: true, // Explicitly enable

        &#8220;edit&#8221;: true

      }

    }

  }

}</code></pre><blockquote><p><strong>Global vs Agent config:</strong> Agent config overrides global.</p></blockquote><div><hr></div><h2>Next Steps: External Tools Integration</h2><p>Agents l&#224; powerful feature &#273;&#7875; specialize AI assistants. Trong b&#224;i ti&#7871;p theo, ch&#250;ng ta s&#7869; kh&#225;m ph&#225; **External Tools: K&#7871;t n&#7889;i m&#7885;i th&#7913;** - c&#225;ch integrate OpenCode v&#7899;i LSP servers, MCP servers, v&#224; external tools.</p><p>B&#7841;n s&#7869; h&#7885;c &#273;&#432;&#7907;c:</p><p>- LSP Servers setup (TypeScript, Python, Go)</p><p>- MCP Servers cho database, API, filesystem</p><p>- External tool integration</p><p>- Complete development environment</p><div class="pullquote"><p><strong>Subscribe &#273;&#7875; kh&#244;ng b&#7887; l&#7905;! &#128640;</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://heyhuynhgiabuu.substack.com/subscribe?"><span>Subscribe now</span></a></p></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Exercise cho b&#7841;n</h2><h4>Level 1: Basic Setup</h4><p>1. <strong>Create code reviewer agent:</strong></p><pre><code>opencode agent create

   # Follow prompts to create reviewer</code></pre><p>2. <strong>Test reviewer:</strong></p><p>   - Write some code</p><p>   - Invoke <code>@reviewer</code> to review it</p><p>   - Verify it focuses on review only</p><p>3. <strong>Create docs writer:</strong></p><p>   - Create <code>.opencode/agent/docs-writer.md</code></p><p>   - Test with <code>@docs-writer create README</code></p><h4>Level 2: Team Setup</h4><p>1. <strong>Create team agents:</strong></p><p>   - Reviewer</p><p>   - Security auditor</p><p>   - Docs writer</p><p>2. <strong>Test complete workflow:</strong></p><p>   - Use workflow examples above</p><p>   - Measure time saved</p><p>3. <strong>Commit to Git:</strong></p><p>   - Share <code>.opencode/agent/</code> with team</p><p>   - Document usage in team wiki</p><div><hr></div><h2>&#127873; &#272;&#7915;ng t&#7921; build t&#7915; &#273;&#7847;u: D&#249;ng OpenCodeKit</h2><p>B&#224;i vi&#7871;t n&#224;y cover c&#225;ch t&#7841;o agents t&#7915; zero theo official docs. Nh&#432;ng n&#7871;u b&#7841;n mu&#7889;n <strong>skip 40+ gi&#7901; setup v&#224; config</strong>, h&#227;y th&#7917; <strong><a href="https://opencodekit.xyz">OpencodeKit</a></strong>.</p><h4>OpencodeKit l&#224; g&#236;?</h4><p>OpencodeKit l&#224; <strong>production-ready configuration package</strong> cho OpenCode - b&#7897; configs &#273;&#227; &#273;&#432;&#7907;c battle-tested, s&#7861;n s&#224;ng d&#249;ng ngay.</p><h4>What&#8217;s Included</h4><p>| Component              | Quantity | Description                                                                             |</p><p>| ---------------------- | -------- | --------------------------------------------------------------------------------------- |</p><p>| <strong>Agents</strong>             | 10       | Plan, Build, Rush, Code-Auditor, Oracle, Finder, Docs, Librarian, General, Orchestrator |</p><p>| <strong>Commands</strong>           | 24       | `/plan`, `/quick-build`, `/pr`, `/fix`, `/commit`, v&#224; nhi&#7873;u h&#417;n                         |</p><p>| <strong>Skills</strong>             | 20       | Brainstorming, TDD, subagent-driven-development, code-review, git-worktrees             |</p><p>| <strong>MCP Services</strong>       | 6        | Context7, Exa, GitHub Grep, Backlog, Knowledge Graph                                    |</p><p>| <strong>Anti-Hallucination</strong> | &#9989;       | Task validation, spec enforcement, review gates                                         |</p><h4>Agents trong OpenCodeKit</h4><p>OpenCodeKit &#273;i k&#232;m <strong>10 specialized agents</strong> &#273;&#227; optimize cho t&#7915;ng task:</p><p>| Agent             | Purpose                              | When to use                       |</p><p>| ----------------- | ------------------------------------ | --------------------------------- |</p><p>| <strong>@plan</strong>         | Strategic planning, PRD + spec files | Multi-step features, architecture |</p><p>| <strong>@build</strong>        | Primary execution agent              | Any implementation task           |</p><p>| <strong>@rush</strong>         | Fast execution, minimal planning     | Quick fixes, hotfixes, typos      |</p><p>| <strong>@code-auditor</strong> | Security, quality, test coverage     | Before merging                    |</p><p>| <strong>@oracle</strong>       | Complex debugging, architecture      | Hard bugs, design decisions       |</p><p>| <strong>@finder</strong>       | Fast codebase search                 | Navigating unfamiliar code        |</p><p>| <strong>@docs</strong>         | API docs, config references          | Looking up library usage          |</p><p>| <strong>@librarian</strong>    | Cross-repo GitHub search             | Real-world patterns               |</p><p>| <strong>@general</strong>      | Multi-step exploratory               | Research, undefined scope         |</p><p>| <strong>@orchestrator</strong> | Multi-agent coordination             | Large features (5+ phases)        |</p><h4>Automatic Delegation</h4><p>B&#7841;n kh&#244;ng c&#7847;n manually call agents - Build agent t&#7921; &#273;&#7897;ng delegate:</p><pre><code># You ask:

&#8220;Add authentication to this API&#8221;

# Build agent delegates:

&#8594; @plan (creates auth spec)

&#8594; @docs (looks up better-auth)

&#8594; @build (implements)

&#8594; @code-auditor (security review)</code></pre><h4>5-minute setup</h4><pre><code># Download v&#224; extract OpenCodeKit

# Copy configs v&#224;o ~/.config/opencode/

# Done! Start coding v&#7899;i fully configured environment</code></pre><blockquote><p><strong>&#8594; Xem chi ti&#7871;t t&#7841;i <a href="https://opencodekit.xyz">opencodekit.xyz</a></strong></p></blockquote><div><hr></div><p><strong>Comment below:</strong> Agent n&#224;o b&#7841;n t&#7841;o &#273;&#7847;u ti&#234;n? Share experience c&#7911;a b&#7841;n! &#128170;</p><div><hr></div><p>_&#272;&#226;y l&#224; b&#224;i 7 trong series &#8220;<strong>H&#224;nh Tr&#236;nh L&#7853;p Tr&#236;nh v&#7899;i Opencode</strong>&#8221;. &#272;&#7885;c c&#225;c b&#224;i tr&#432;&#7899;c t&#7841;i <a href="https://substack.com/@heyhuynhgiabuu">series overview</a>._</p>]]></content:encoded></item><item><title><![CDATA[OpenCode code quality: Formatters và rules]]></title><description><![CDATA[T&#7915; code "t&#224;m t&#7841;m" &#273;&#7871;n chu&#7849;n qu&#7889;c t&#7871;]]></description><link>https://heyhuynhgiabuu.substack.com/p/opencode-code-quality-formatters</link><guid isPermaLink="false">https://heyhuynhgiabuu.substack.com/p/opencode-code-quality-formatters</guid><dc:creator><![CDATA[Huynh Gia Buu]]></dc:creator><pubDate>Mon, 17 Nov 2025 16:08:09 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/19a61bdc-de85-480e-a665-334196d678e3_3398x1852.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>T&#244;i &#273;&#227; t&#7915;ng l&#224; &#8220;cha &#273;&#7867;&#8221; c&#7911;a code spaghetti</h2><p>H&#244;m kia t&#244;i review PR c&#7911;a m&#7897;t junior. Code ch&#7841;y &#273;&#250;ng, logic &#7893;n, nh&#432;ng...</p><pre><code>function getUserData(id) {

  var user = db.query(&#8221;SELECT * FROM users WHERE id = &#8220; + id);

  if (user.length &gt; 0) {

    return user[0];

  } else {

    return null;

  }

}</code></pre><p>Spacing inconsistent, no semicolons, SQL injection vulnerability, var thay v&#236; let. T&#7889;n 20 ph&#250;t ch&#7881; &#273;&#7875; format v&#224; fix basic issues.</p><p>&#272;&#243; l&#224; khi t&#244;i nh&#7853;n ra: <strong>Code quality kh&#244;ng ph&#7843;i l&#224; optional, n&#243; l&#224; survival skill</strong>.</p><p>H&#244;m nay t&#244;i s&#7869; ch&#7881; b&#7841;n c&#225;ch setup OpenCode &#273;&#7875; auto-enforce code standards - bi&#7871;n team t&#7915; &#8220;cha &#273;&#7867; c&#7911;a spaghetti&#8221; th&#224;nh &#8220;s&#7843;n xu&#7845;t code chu&#7849;n Michelin&#8221;.</p><div><hr></div><h2>T&#7841;i sao Code Quality quan tr&#7885;ng h&#417;n bao gi&#7901; h&#7871;t?</h2><h4>C&#225;i gi&#225; &#7849;n s&#226;u c&#7911;a Bad Code</h4><p><strong>Direct costs:</strong></p><p>- 20% time wasted tr&#234;n formatting issues</p><p>- 30% bugs t&#7915; inconsistent patterns</p><p>- 40% code review time cho basic style issues</p><p><strong>Hidden costs:</strong></p><p>- New developer onboarding: 2 weeks &#8594; 2 months</p><p>- Knowledge transfer: &#8220;Code n&#224;y ai vi&#7871;t?&#8221; &#8594; &#8220;Kh&#244;ng ai hi&#7875;u&#8221;</p><p>- Technical debt: &#8220;Fix sau&#8221; &#8594; &#8220;Never fix&#8221;</p><p><strong>ROI c&#7911;a Good Code:</strong></p><p>- 50% faster code reviews</p><p>- 70% fewer style-related bugs</p><p>- 90% faster onboarding for new devs</p><div><hr></div><h2>OpenCode Formatters: Auto-magic Code Cleanup</h2><p>OpenCode t&#7921; &#273;&#7897;ng format files sau khi write ho&#7863;c edit - &#273;&#7843;m b&#7843;o code generated lu&#244;n follow code style c&#7911;a project.</p><h4>Built-in Formatters Overview</h4><p>OpenCode c&#243; **<strong>11 built-in formatters</strong>** cho popular languages:</p><p>| Formatter          | Extensions                                           | Requirements                               |</p><p>| ------------------ | ---------------------------------------------------- | ------------------------------------------ |</p><p>| **prettier**       | .js, .jsx, .ts, .tsx, .html, .css, .md, .json, .yaml | `prettier` dependency trong `package.json` |</p><p>| **biome**          | .js, .jsx, .ts, .tsx, .html, .css, .md, .json, .yaml | `biome.json(c)` config file                |</p><p>| **ruff**           | .py, .pyi                                            | `ruff` command available v&#7899;i config        |</p><p>| **uv**             | .py, .pyi                                            | `uv` command available                     |</p><p>| **gofmt**          | .go                                                  | `gofmt` command available                  |</p><p>| **zig**            | .zig, .zon                                           | `zig` command available                    |</p><p>| **clang-format**   | .c, .cpp, .h, .hpp, .ino                             | `.clang-format` config file                |</p><p>| **ktlint**         | .kt, .kts                                            | `ktlint` command available                 |</p><p>| **rubocop**        | .rb, .rake, .gemspec, .ru                            | `rubocop` command available                |</p><p>| **standardrb**     | .rb, .rake, .gemspec, .ru                            | `standardrb` command available             |</p><p>| **htmlbeautifier** | .erb, .html.erb                                      | `htmlbeautifier` command available         |</p><h4>C&#225;ch Formatters Ho&#7841;t &#272;&#7897;ng</h4><p>Khi OpenCode write ho&#7863;c edit file:</p><p>1. <strong>Check file extension</strong> against all enabled formatters</p><p>2. <strong>Run formatter command</strong> on the file</p><p>3. <strong>Apply formatting changes</strong> t&#7921; &#273;&#7897;ng</p><p>T&#7845;t c&#7843; di&#7877;n ra &#7903; background - code style lu&#244;n maintained m&#224; kh&#244;ng c&#7847;n manual steps!</p><div><hr></div><h2>Configure Formatters: T&#249;y ch&#7881;nh theo team</h2><h4>Basic Configuration</h4><p><strong>Global config trong </strong><code>opencode.json</code><strong>:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {}

}</code></pre><h4>Disable Formatters</h4><p>Kh&#244;ng mu&#7889;n d&#249;ng m&#7897;t formatter c&#7909; th&#7875;? Disable n&#243;:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;prettier&#8221;: {

      &#8220;disabled&#8221;: true

    }

  }

}</code></pre><h4>Custom Formatter Configuration</h4><p>Override built-in formatters ho&#7863;c add new ones:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;prettier&#8221;: {

      &#8220;command&#8221;: [&#8221;npx&#8221;, &#8220;prettier&#8221;, &#8220;--write&#8221;, &#8220;$FILE&#8221;],

      &#8220;environment&#8221;: {

        &#8220;NODE_ENV&#8221;: &#8220;development&#8221;

      },

      &#8220;extensions&#8221;: [&#8221;.js&#8221;, &#8220;.ts&#8221;, &#8220;.jsx&#8221;, &#8220;.tsx&#8221;]

    },

    &#8220;custom-markdown-formatter&#8221;: {

      &#8220;command&#8221;: [&#8221;deno&#8221;, &#8220;fmt&#8221;, &#8220;$FILE&#8221;],

      &#8220;extensions&#8221;: [&#8221;.md&#8221;]

    }

  }

}</code></pre><p><strong>Key points:</strong></p><p>- <code>command</code>: Array of command parts, <code>$FILE</code> placeholder s&#7869; replaced v&#7899;i file path</p><p>- <code>environment</code>: Environment variables khi run formatter</p><p>- <code>extensions</code>: File extensions formatter n&#234;n handle</p><p>- <code>disabled</code>: Set <code>true</code> &#273;&#7875; disable formatter</p><h4>Formatter Options cho t&#7915;ng Language</h4><p><strong>JavaScript/TypeScript v&#7899;i Prettier:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;prettier&#8221;: {

      &#8220;command&#8221;: [

        &#8220;npx&#8221;,

        &#8220;prettier&#8221;,

        &#8220;--write&#8221;,

        &#8220;--config&#8221;,

        &#8220;.prettierrc.json&#8221;,

        &#8220;$FILE&#8221;

      ],

      &#8220;extensions&#8221;: [&#8221;.js&#8221;, &#8220;.jsx&#8221;, &#8220;.ts&#8221;, &#8220;.tsx&#8221;, &#8220;.json&#8221;, &#8220;.md&#8221;]

    }

  }

}</code></pre><p><strong>Python v&#7899;i Ruff:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;ruff&#8221;: {

      &#8220;command&#8221;: [&#8221;ruff&#8221;, &#8220;format&#8221;, &#8220;$FILE&#8221;],

      &#8220;extensions&#8221;: [&#8221;.py&#8221;, &#8220;.pyi&#8221;]

    }

  }

}</code></pre><p><strong>Go v&#7899;i gofmt:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;gofmt&#8221;: {

      &#8220;command&#8221;: [&#8221;gofmt&#8221;, &#8220;-w&#8221;, &#8220;$FILE&#8221;],

      &#8220;extensions&#8221;: [&#8221;.go&#8221;]

    }

  }

}</code></pre><div><hr></div><h2>AGENTS.md: Custom Instructions cho OpenCode</h2><p><code>AGENTS.md</code> l&#224; &#8220;lu&#7853;t ch&#417;i&#8221; c&#7911;a project - instructions &#273;&#432;&#7907;c include trong LLM context &#273;&#7875; customize behavior.</p><h4>Initialize AGENTS.md</h4><p><strong>Quick start v&#7899;i </strong><code>/init</code><strong> command:</strong></p><pre><code># Trong OpenCode TUI

/init
</code></pre><p>OpenCode s&#7869;:</p><p>1. Scan project v&#224; all contents</p><p>2. Understand project structure</p><p>3. Generate <code>AGENTS.md</code> v&#7899;i relevant instructions</p><p>4. Add to existing file n&#7871;u &#273;&#227; c&#243;</p><blockquote><p><strong>Pro tip:</strong> Commit <code>AGENTS.md</code> v&#224;o Git &#273;&#7875; share v&#7899;i team!</p></blockquote><h4>Example AGENTS.md</h4><p><strong>SST v3 Monorepo Project:</strong></p><pre><code># SST v3 Monorepo Project

This is an SST v3 monorepo with TypeScript. The project uses bun workspaces for package management.

## Project Structure

- `packages/` - Contains all workspace packages (functions, core, web, etc.)

- `infra/` - Infrastructure definitions split by service (storage.ts, api.ts, web.ts)

- `sst.config.ts` - Main SST configuration with dynamic imports

## Code Standards

- Use TypeScript with strict mode enabled

- Shared code goes in `packages/core/` with proper exports configuration

- Functions go in `packages/functions/`

- Infrastructure should be split into logical files in `infra/`

## Monorepo Conventions

- Import shared modules using workspace names: `@my-app/core/example`</code></pre><p><strong>React Project Example:</strong></p><pre><code># React TypeScript Project

Modern React application with TypeScript, TanStack Router, and Tailwind CSS.

## Project Structure

- `src/components/` - Reusable UI components

- `src/pages/` - Route components

- `src/hooks/` - Custom React hooks

- `src/utils/` - Utility functions

- `src/types/` - TypeScript type definitions

## Code Standards

- Use functional components with TypeScript

- Prefer named exports over default exports

- Use TanStack Router for routing

- Style with Tailwind CSS utility classes

- Write tests with Vitest and Testing Library

## Naming Conventions

- Components: PascalCase (Button.tsx)

- Hooks: camelCase with &#8220;use&#8221; prefix (useAuth.ts)

- Utils: camelCase (formatDate.ts)

- Types: PascalCase (User.ts)

## Forbidden Patterns

- No `any` types

- No default exports

- No prop spreading without explicit interface

- No inline styles (use Tailwind)</code></pre><div><hr></div><h2>Types of AGENTS.md: Project vs Global</h2><h4>Project-Specific Rules</h4><p><strong>Location:</strong> Project root <code>AGENTS.md</code></p><pre><code># My Project Rules

Project-specific instructions that apply only when working in this directory.

These are shared with team via Git.

## Project Structure

- `src/` - Source code

- `tests/` - Test files

- `docs/` - Documentation

## Team Conventions

- Use conventional commits

- Run tests before commit

- Keep PRs small (&lt; 400 lines)</code></pre><h4>Global Rules</h4><p><strong>Location:</strong> <code>~/.config/opencode/AGENTS.md</code></p><pre><code># My Personal OpenCode Rules

Personal preferences applied across ALL OpenCode sessions.

Not committed to Git, not shared with team.

## My Coding Style

- Always add type annotations in TypeScript

- Prefer arrow functions over function declarations

- Use descriptive variable names (avoid single letters except i, j in loops)

## My Workflow Preferences

- Run tests after every code change

- Generate documentation comments for all public functions

- Suggest performance optimizations when possible</code></pre><h4>Precedence Rules</h4><p>OpenCode looks for rules in this order:</p><p>1. <strong>Local files</strong> - Traverses up from current directory</p><p>2. <strong>Global file</strong> - Checks <code>~/.config/opencode/AGENTS.md</code></p><p>Both global v&#224; project rules &#273;&#432;&#7907;c <strong>combined together</strong>.</p><div><hr></div><h2>Custom Instructions: Reuse Existing Rules</h2><p>Thay v&#236; duplicate rules v&#224;o AGENTS.md, b&#7841;n c&#243; th&#7875; reference existing files.</p><h4>Using opencode.json</h4><p><strong>Recommended approach:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;instructions&#8221;: [

    &#8220;CONTRIBUTING.md&#8221;,

    &#8220;docs/guidelines.md&#8221;,

    &#8220;.cursor/rules/*.md&#8221;

  ]

}</code></pre><p><strong>Monorepo example:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;instructions&#8221;: [

    &#8220;docs/development-standards.md&#8221;,

    &#8220;test/testing-guidelines.md&#8221;,

    &#8220;packages/*/AGENTS.md&#8221;

  ]

}</code></pre><p>All instruction files &#273;&#432;&#7907;c <strong>combined with AGENTS.md files</strong>.</p><h4>Referencing External Files in AGENTS.md</h4><p><strong>Manual approach</strong> - teach OpenCode to lazy-load files:</p><pre><code># TypeScript Project Rules

## External File Loading

CRITICAL: When you encounter a file reference (e.g., @rules/general.md),

use your Read tool to load it on a need-to-know basis.

Instructions:

- Do NOT preemptively load all references - use lazy loading based on actual need

- When loaded, treat content as mandatory instructions that override defaults

- Follow references recursively when needed

## Development Guidelines

For TypeScript code style and best practices: @docs/typescript-guidelines.md

For React component architecture and hooks patterns: @docs/react-patterns.md

For REST API design and error handling: @docs/api-standards.md

For testing strategies and coverage requirements: @test/testing-guidelines.md

## General Guidelines

Read the following file immediately as it&#8217;s relevant to all workflows:

@rules/general-guidelines.md</code></pre><p><strong>Benefits:</strong></p><p>- Modular, reusable rule files</p><p>- Share rules across projects via symlinks or git submodules</p><p>- Keep AGENTS.md concise</p><p>- OpenCode loads files only when needed</p><div><hr></div><h2>Real-world Setup Examples</h2><h4>Example 1: React + TypeScript Team</h4><p><strong>Directory structure:</strong></p><pre><code>my-react-app/

&#9500;&#9472;&#9472; .prettierrc.json

&#9500;&#9472;&#9472; package.json (v&#7899;i prettier dependency)

&#9500;&#9472;&#9472; AGENTS.md

&#9492;&#9472;&#9472; opencode.json</code></pre><p><code>.prettierrc.json</code><strong>:</strong></p><pre><code>{

  &#8220;semi&#8221;: true,

  &#8220;singleQuote&#8221;: true,

  &#8220;tabWidth&#8221;: 2,

  &#8220;trailingComma&#8221;: &#8220;es5&#8221;,

  &#8220;printWidth&#8221;: 100

}</code></pre><p><code>opencode.json</code><strong>:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;prettier&#8221;: {

      &#8220;command&#8221;: [&#8221;npx&#8221;, &#8220;prettier&#8221;, &#8220;--write&#8221;, &#8220;$FILE&#8221;]

    }

  },

  &#8220;instructions&#8221;: [&#8221;docs/react-guidelines.md&#8221;]

}</code></pre><p><code>AGENTS.md</code>:</p><pre><code># React TypeScript Project

Modern React app with TypeScript and Prettier formatting.

## Code Standards

- Use TypeScript strict mode

- Format with Prettier (auto-configured)

- Write tests with Vitest

- Use named exports only

## Component Structure

- Functional components only

- Props interface for all components

- Use custom hooks for logic reuse

For detailed React patterns: @docs/react-guidelines.md</code></pre><h4>Example 2: Python Microservices</h4><p><strong>Directory structure:</strong></p><pre><code>python-service/

&#9500;&#9472;&#9472; pyproject.toml (v&#7899;i ruff config)

&#9500;&#9472;&#9472; AGENTS.md

&#9492;&#9472;&#9472; opencode.json</code></pre><p><code>pyproject.toml</code>:</p><pre><code>[tool.ruff]

line-length = 88

target-version = &#8220;py311&#8221;

[tool.ruff.lint]

select = [&#8221;E&#8221;, &#8220;F&#8221;, &#8220;I&#8221;]

ignore = [&#8221;E501&#8221;]</code></pre><p><code>opencode.json</code>:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;ruff&#8221;: {

      &#8220;command&#8221;: [&#8221;ruff&#8221;, &#8220;format&#8221;, &#8220;$FILE&#8221;]

    }

  },

  &#8220;instructions&#8221;: [&#8221;docs/api-standards.md&#8221;, &#8220;docs/testing-guide.md&#8221;]

}</code></pre><p><code>AGENTS.md</code>:</p><pre><code># Python Microservice

FastAPI-based microservice with Ruff formatting and strict typing.

## Project Structure

- `app/` - Application code

- `tests/` - Pytest tests

- `docs/` - API documentation

## Code Standards

- Use type hints everywhere

- Format with Ruff (auto-configured)

- Write docstrings for all public functions

- Use Pydantic for data validation

## API Design

Follow REST best practices: @docs/api-standards.md

For testing strategies: @docs/testing-guide.md</code></pre><h4>Example 3: Monorepo v&#7899;i Multiple Languages</h4><p><strong>Directory structure</strong>:</p><pre><code>monorepo/

&#9500;&#9472;&#9472; packages/

&#9474;   &#9500;&#9472;&#9472; frontend/ (React + TypeScript)

&#9474;   &#9500;&#9472;&#9472; backend/ (Node.js + TypeScript)

&#9474;   &#9492;&#9472;&#9472; shared/ (TypeScript)

&#9500;&#9472;&#9472; AGENTS.md

&#9492;&#9472;&#9472; opencode.json</code></pre><p><code>opencode.json</code>:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;formatter&#8221;: {

    &#8220;prettier&#8221;: {

      &#8220;command&#8221;: [&#8221;npx&#8221;, &#8220;prettier&#8221;, &#8220;--write&#8221;, &#8220;$FILE&#8221;],

      &#8220;extensions&#8221;: [&#8221;.js&#8221;, &#8220;.jsx&#8221;, &#8220;.ts&#8221;, &#8220;.tsx&#8221;, &#8220;.json&#8221;, &#8220;.md&#8221;]

    }

  },

  &#8220;instructions&#8221;: [&#8221;docs/monorepo-guidelines.md&#8221;, &#8220;packages/*/AGENTS.md&#8221;]

}</code></pre><p><strong>Root </strong><code>AGENTS.md</code><strong>:</strong></p><pre><code># Monorepo Project

Shared instructions for all packages in this monorepo.

## Monorepo Structure

- `packages/frontend/` - React application

- `packages/backend/` - Node.js API

- `packages/shared/` - Shared utilities and types

## Shared Standards

- Use TypeScript strict mode across all packages

- Format with Prettier (unified config)

- Share types via `@monorepo/shared` package

- Use workspace protocol for internal dependencies

## Package-Specific Rules

Each package has its own AGENTS.md loaded via opencode.json instructions.

For monorepo best practices: @docs/monorepo-guidelines.md</code></pre><p><code>packages/frontend/AGENTS.md</code>:</p><pre><code># Frontend Package

React + TypeScript frontend application.

## Frontend-Specific Standards

- Use TanStack Router for routing

- Style with Tailwind CSS

- Test with Vitest + Testing Library

- Import shared types from `@monorepo/shared`</code></pre><div><hr></div><h2>Best Practices cho Code Quality Setup</h2><h4>1. Start Simple, Scale Gradually</h4><p><strong>Week 1-2: Basic Formatting</strong></p><p>- Setup Prettier/Ruff v&#7899;i default config</p><p>- Add basic AGENTS.md v&#7899;i project structure</p><p>- No enforcement, just auto-format</p><p><strong>Week 3-4: Add Project Standards</strong></p><p>- Create comprehensive AGENTS.md</p><p>- Add custom instructions files</p><p>- Document naming conventions</p><p><strong>Week 5-6: Team Alignment</strong></p><p>- Share setup v&#7899;i team</p><p>- Collect feedback v&#224; adjust</p><p>- Add team-specific rules</p><p><strong>Week 7+: Enforcement</strong></p><p>- Add pre-commit hooks (n&#7871;u c&#7847;n)</p><p>- Monitor code quality metrics</p><p>- Continuous improvement</p><h4>2. Keep AGENTS.md Focused</h4><p><strong>Do:</strong></p><blockquote><p>- Explain project structure clearly</p><p>- Document team conventions</p><p>- Reference external guidelines</p><p>- Include forbidden patterns</p></blockquote><p><strong>Don&#8217;t:</strong></p><blockquote><p>- Duplicate formatter config (&#273;&#227; c&#243; trong .prettierrc)</p><p>- Include personal preferences (d&#249;ng global AGENTS.md)</p><p>- Write essays (keep it concise)</p><p>- Hardcode file paths (use references)</p></blockquote><h4>3. Leverage opencode.json for Reusability</h4><p><strong>Good pattern:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;instructions&#8221;: [&#8221;docs/shared-standards.md&#8221;, &#8220;CONTRIBUTING.md&#8221;]

}</code></pre><p><strong>Better pattern:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;instructions&#8221;: [&#8221;docs/standards/*.md&#8221;, &#8220;packages/*/AGENTS.md&#8221;]

}</code></pre><h4>4. Test Your Setup</h4><p><strong>Checklist:</strong></p><p>- [ ] Run `/init` in OpenCode TUI</p><p>- [ ] Edit a file v&#224; verify auto-formatting works</p><p>- [ ] Check AGENTS.md instructions are followed</p><p>- [ ] Test external file references load correctly</p><p>- [ ] Verify team members can replicate setup</p><div><hr></div><h2>Measuring Code Quality Improvement</h2><h4>Before OpenCode Setup</h4><p><strong>Metrics:</strong></p><p>- Code review time: 45 minutes average</p><p>- Formatting discussions: 30% of review comments</p><p>- Style-related bugs: 15 per sprint</p><p>- Onboarding time: 3 weeks</p><p>- Code consistency score: 6/10</p><h4>After OpenCode Setup</h4><p><strong>Metrics:</strong></p><p>- Code review time: 15 minutes average (-67%)</p><p>- Formatting discussions: 2% of review comments (-93%)</p><p>- Style-related bugs: 2 per sprint (-87%)</p><p>- Onboarding time: 1 week (-67%)</p><p>- Code consistency score: 9/10 (+50%)</p><h4>Track Your Progress</h4><p><strong>Simple tracking script:</strong></p><pre><code>#!/bin/bash

# quality-metrics.sh

echo &#8220;&#128202; Code Quality Metrics&#8221;

echo &#8220;=======================&#8221;

echo &#8220;&#128221; Files formatted last week:&#8221;

git log --since=&#8221;1 week ago&#8221; --name-only --pretty=format: | sort -u | wc -l

echo &#8220;&#128269; Prettier changes in last week:&#8221;

git log --since=&#8221;1 week ago&#8221; --grep=&#8221;prettier&#8221; --oneline | wc -l

echo &#8220;&#128207; Average PR size (lines):&#8221;

gh pr list --state merged --limit 10 --json additions,deletions \

  | jq &#8216;[.[] | .additions + .deletions] | add / length&#8217;</code></pre><div><hr></div><h2>Troubleshooting Common Issues</h2><h4>Issue 1: Formatter Not Running</h4><p><strong>Check 1: Formatter requirements met?</strong></p><pre><code># For Prettier

cat package.json | grep prettier

# For Ruff

ruff --version

# For gofmt

gofmt -help</code></pre><p><strong>Check 2: File extension supported?</strong></p><pre><code>{

  &#8220;formatter&#8221;: {

    &#8220;prettier&#8221;: {

      &#8220;extensions&#8221;: [&#8221;.js&#8221;, &#8220;.ts&#8221;, &#8220;.jsx&#8221;, &#8220;.tsx&#8221;]

    }

  }

}</code></pre><p><strong>Check 3: Formatter not disabled?</strong></p><pre><code>{

  &#8220;formatter&#8221;: {

    &#8220;prettier&#8221;: {

      &#8220;disabled&#8221;: false // Make sure this is false

    }

  }

}</code></pre><h4>Issue 2: AGENTS.md Not Loaded</h4><p><strong>Debug v&#7899;i OpenCode TUI:</strong></p><pre><code># Check n&#7871;u file &#273;&#432;&#7907;c recognized

opencode --verbose

# Verify file location

ls -la AGENTS.md

ls -la ~/.config/opencode/AGENTS.md</code></pre><p><strong>Common mistakes:</strong></p><p>- File trong wrong directory</p><p>- Typo trong filename (ph&#7843;i l&#224; <code>AGENTS.md</code>, kh&#244;ng ph&#7843;i <code>agents.md</code>)</p><p>- Git kh&#244;ng track file</p><h4>Issue 3: Formatting Conflicts</h4><p><strong>Prettier vs ESLint conflicts:</strong></p><p>Disable conflicting ESLint rules:</p><pre><code>{

  &#8220;extends&#8221;: [

    &#8220;eslint:recommended&#8221;,

    &#8220;prettier&#8221; // Must be LAST to override

  ]

}</code></pre><p>Install eslint-config-prettier:</p><pre><code>npm install -D eslint-config-prettier</code></pre><div><hr></div><h2>Team Onboarding Checklist</h2><h4>For New Team Members</h4><p><strong>Setup steps:</strong></p><p><strong>1. Clone repo:</strong></p><pre><code>   git clone &lt;repo-url&gt;

   cd &lt;repo&gt;</code></pre><p><strong>2. Install dependencies:</strong></p><pre><code>   npm install  # or yarn/pnpm</code></pre><p><strong>3. Check OpenCode config:</strong></p><pre><code>   cat opencode.json

   cat AGENTS.md</code></pre><p><strong>4. Run OpenCode:</strong></p><pre><code>   opencode</code></pre><p><strong>5. Test formatting:</strong></p><p>   - Edit m&#7897;t file</p><p>   - Save v&#224; verify auto-format</p><p>   - Run <code>/init</code> &#273;&#7875; verify <code>AGENTS.md</code> loaded</p><p><strong>6. Read team guidelines:</strong></p><p>   - Check <code>AGENTS.md</code> for project structure</p><p>   - Review files referenced trong `instructions`</p><p>   - Ask questions trong team chat</p><h4>For Team Leads</h4><p><strong>Maintenance checklist:</strong></p><blockquote><p>- [ ] Review AGENTS.md quarterly</p><p>- [ ] Update formatter configs when upgrading dependencies</p><p>- [ ] Collect feedback on pain points</p><p>- [ ] Document new patterns discovered</p><p>- [ ] Keep instructions files up-to-date</p><p>- [ ] Share success stories v&#7899;i team</p></blockquote><div><hr></div><h2>Next Steps: Agents &amp; Rules</h2><p>Code quality l&#224; foundation cho consistent codebase. Trong b&#224;i ti&#7871;p theo, ch&#250;ng ta s&#7869; kh&#225;m ph&#225; <strong>Agents &amp; Rules: AI assistant chuy&#234;n nghi&#7879;p</strong> - c&#225;ch t&#7841;o specialized AI agents cho t&#7915;ng lo&#7841;i c&#244;ng vi&#7879;c.</p><p>B&#7841;n s&#7869; h&#7885;c &#273;&#432;&#7907;c:</p><p>- Specialized agents (reviewer, planner, build)</p><p>- Custom agent configuration cho team workflows</p><p>- Agent best practices v&#224; pitfalls to avoid</p><p>- Real-world agent workflows</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p><strong>Subscribe &#273;&#7875; kh&#244;ng b&#7887; l&#7905;! &#128640;</strong></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><h2>Exercise cho b&#7841;n</h2><h4>Level 1: Basic Setup</h4><p>1. <strong>Create AGENTS.md cho project c&#7911;a b&#7841;n:</strong></p><p>   - Run <code>/init</code> trong OpenCode</p><p>   - Review generated content</p><p>   - Add project-specific conventions</p><p>   - Commit to Git</p><p>2. <strong>Configure formatters:</strong></p><p>   - Check which formatter applies to your project</p><p>   - Add opencode.json n&#7871;u c&#7847;n custom config</p><p>   - Test formatting on sample file</p><p>3. <strong>Verify setup:</strong></p><p>   - Edit m&#7897;t file v&#224; check auto-format</p><p>   - Ask OpenCode v&#7873; project structure</p><p>   - Confirm AGENTS.md instructions followed</p><h4>Level 2: Team Integration</h4><p><strong>1.</strong> <strong>Create instruction files:</strong></p><p>   - <code>docs/coding-standards.md</code></p><p>   - <code>docs/testing-guide.md</code></p><p>   - Reference them trong <code>opencode.json</code></p><p><strong>2. Setup global rules:</strong></p><p>   - Create <code>~/.config/opencode/AGENTS.md</code></p><p>   - Add personal preferences</p><p>   - Test project vs global precedence</p><p><strong>3.</strong> <strong>Document for team:</strong></p><p>   - Write onboarding guide</p><p>   - Create setup script</p><p>   - Share trong team wiki</p><h4>Level 3: Advanced</h4><p><strong>1.</strong> <strong>Measure improvements:</strong></p><p>   - Track formatting time saved</p><p>   - Monitor code review efficiency</p><p>   - Survey team satisfaction</p><p><strong>2.</strong> <strong>Optimize setup</strong>:</p><p>   - Fine-tune formatter configs</p><p>   - Reorganize instruction files</p><p>   - Create language-specific guides</p><p><strong>3. Share learnings:</strong></p><p>   - Write internal blog post</p><p>   - Present trong team meeting</p><p>   - Contribute improvements back to team</p><p><strong>Comment below:</strong> Setup experience v&#224; results! C&#249;ng nhau build better practices! &#128170;</p><div><hr></div><p>_&#272;&#226;y l&#224; b&#224;i 6 trong series &#8220;<strong>H&#224;nh Tr&#236;nh L&#7853;p Tr&#236;nh v&#7899;i Opencode</strong>&#8221;. &#272;&#7885;c c&#225;c b&#224;i tr&#432;&#7899;c t&#7841;i [<a href="https://heyhuynhgiabuu.substack.com/">series overview</a>]._</p>]]></content:encoded></item><item><title><![CDATA[Opencode Commands & Automation: Tự động hoá mọi thứ]]></title><description><![CDATA[OpenCode commands: Automation cho developer Vi&#7879;t]]></description><link>https://heyhuynhgiabuu.substack.com/p/opencode-commands-and-automation</link><guid isPermaLink="false">https://heyhuynhgiabuu.substack.com/p/opencode-commands-and-automation</guid><dc:creator><![CDATA[Huynh Gia Buu]]></dc:creator><pubDate>Fri, 31 Oct 2025 17:54:40 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/2c9686d0-cd47-46a3-8ba2-ca15230702de_2526x2734.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="pullquote"><p>80% c&#244;ng vi&#7879;c l&#7863;p &#273;i l&#7863;p l&#7841;i &#8594; 5 ph&#250;t setup</p></div><h3>T&#244;i &#273;&#227; t&#7915;ng l&#224; &#8220;con robot&#8221; c&#7911;a terminal</h3><p>M&#7895;i s&#225;ng &#273;&#7871;n c&#244;ng ty, t&#244;i l&#7841;i l&#7863;p &#273;i l&#7863;p l&#7841;i m&#7897;t chu&#7895;i commands:</p><pre><code>git pull origin main

npm install

npm run test

npm run build

docker-compose up -d</code></pre><p>&#272;&#244;i khi c&#242;n ph&#7843;i check lint, format code, deploy... M&#7845;t 15 ph&#250;t m&#7895;i ng&#224;y ch&#7881; cho vi&#7879;c &#8220;setup&#8221;. Cho &#273;&#7871;n khi t&#244;i kh&#225;m ph&#225; ra OpenCode Commands - game changer th&#7921;c s&#7921;.</p><p>H&#244;m nay t&#244;i s&#7869; ch&#7881; b&#7841;n c&#225;ch bi&#7871;n 80% c&#244;ng vi&#7879;c l&#7863;p l&#7841;i th&#224;nh v&#224;i c&#225;i g&#245; ph&#237;m.</p><div><hr></div><h3>Commands l&#224; g&#236; trong OpenCode?</h3><p>OpenCode Commands cho ph&#233;p b&#7841;n t&#7841;o ra c&#225;c &#8220;l&#7889;i t&#7855;t th&#244;ng minh&#8221; - nh&#7919;ng c&#226;u l&#7879;nh t&#249;y ch&#7881;nh m&#224; khi b&#7841;n g&#245; <code>/t&#234;n-command</code>, OpenCode s&#7869; t&#7921; &#273;&#7897;ng th&#7921;c hi&#7879;n m&#7897;t chu&#7895;i h&#224;nh &#273;&#7897;ng ph&#7913;c t&#7841;p.</p><p><strong>V&#237; d&#7909; th&#7921;c t&#7871;:</strong></p><ul><li><p><code>/test</code> &#8594; Ch&#7841;y full test suite, analyze failures, suggest fixes</p></li><li><p><code>/review</code> &#8594; Review code changes theo team standards</p></li><li><p><code>/deploy</code> &#8594; Build, test, deploy m&#7897;t l&#7847;n</p></li></ul><p>Kh&#244;ng ch&#7881; l&#224; simple aliases, Commands c&#243; th&#7875;:</p><ul><li><p>Nh&#7853;n arguments (`$1`, `$2`, `$ARGUMENTS`)</p></li><li><p>Ch&#7841;y shell commands v&#224; inject output</p></li><li><p>Include files t&#7921; &#273;&#7897;ng</p></li><li><p>S&#7917; d&#7909;ng agents v&#224; models kh&#225;c nhau</p></li></ul><div><hr></div><h3>T&#7841;o Command &#273;&#7847;u ti&#234;n: Magic Test Runner</h3><h4>C&#225;ch 1: D&#249;ng Markdown file (recommended)</h4><p>T&#7841;o file `.opencode/command/test.md`:</p><pre><code>---

description: Run tests with coverage and analyze failures

agent: build

model: anthropic/claude-3-5-sonnet-20241022

---

Run the full test suite with coverage report and show any failures.

Focus on the failing tests and suggest fixes.

Current test results:

!`npm test -- --coverage`

Recent changes that might affect tests:

!`git log --oneline -5`</code></pre><h4>C&#225;ch 2: D&#249;ng JSON config</h4><p>Trong <code>opencode.json</code>:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;command&#8221;: {

    &#8220;test&#8221;: {

      &#8220;template&#8221;: &#8220;Run the full test suite with coverage report and show any failures.\nFocus on the failing tests and suggest fixes.\n\nCurrent test results:\n!`npm test -- --coverage`&#8221;,

      &#8220;description&#8221;: &#8220;Run tests with coverage&#8221;,

      &#8220;agent&#8221;: &#8220;build&#8221;,

      &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;

    }

  }

}</code></pre><p><strong>S&#7917; d&#7909;ng:</strong> G&#245; <code>/test</code> trong TUI v&#224; xem magic happens!</p><div><hr></div><h3>Command Options: Full Control</h3><p>OpenCode Commands cung c&#7845;p nhi&#7873;u options &#273;&#7875; b&#7841;n ki&#7875;m so&#225;t ch&#237;nh x&#225;c c&#225;ch command th&#7921;c thi:</p><h4>Template Option</h4><p><code>template</code> l&#224; ph&#7847;n <strong>b&#7855;t bu&#7897;c</strong> - &#273;&#7883;nh ngh&#297;a prompt s&#7869; g&#7917;i &#273;&#7871;n LLM:</p><pre><code>{

  &#8220;command&#8221;: {

    &#8220;test&#8221;: {

      &#8220;template&#8221;: &#8220;Run tests and analyze failures:\n!`npm test`\n\nFocus on failing tests and suggest fixes.&#8221;

    }

  }

}</code></pre><h4>Description Option</h4><p><code>description</code> hi&#7875;n th&#7883; trong TUI khi b&#7841;n g&#245; <code>/</code>:</p><pre><code>{

  &#8220;command&#8221;: {

    &#8220;test&#8221;: {

      &#8220;description&#8221;: &#8220;Run tests with intelligent failure analysis&#8221;

    }

  }

}</code></pre><h4>Agent Option</h4><p>Ch&#7881; &#273;&#7883;nh agent n&#224;o s&#7869; th&#7921;c thi command:</p><pre><code>{

  &#8220;command&#8221;: {

    &#8220;review&#8221;: {

      &#8220;agent&#8221;: &#8220;reviewer&#8221;,

      &#8220;template&#8221;: &#8220;Review code changes for quality and security&#8221;

    },

    &#8220;plan&#8221;: {

      &#8220;agent&#8221;: &#8220;plan&#8221;,

      &#8220;template&#8221;: &#8220;Create implementation plan for new feature&#8221;

    }

  }

}

</code></pre><h4>Model Option</h4><p>Override model m&#7863;c &#273;&#7883;nh cho command c&#7909; th&#7875;:</p><pre><code>{

  &#8220;command&#8221;: {

    &#8220;analyze&#8221;: {

      &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

      &#8220;template&#8221;: &#8220;Deep analyze code for performance issues&#8221;

    }

  }

}</code></pre><h4>Subtask Option</h4><p>Force command ch&#7841;y nh&#432; subtask (kh&#244;ng pollute primary context):</p><pre><code>{

  &#8220;command&#8221;: {

    &#8220;quick-check&#8221;: {

      &#8220;subtask&#8221;: true,

      &#8220;template&#8221;: &#8220;Quick syntax check and basic validation&#8221;

    }

  }

}</code></pre><p><strong>Khi n&#224;o d&#249;ng </strong><code>subtask: true</code><strong>:</strong></p><ul><li><p>Commands ch&#7841;y th&#432;&#7901;ng xuy&#234;n (linting, formatting)</p></li><li><p>Tasks kh&#244;ng c&#7847;n context ch&#237;nh</p></li><li><p>Mu&#7889;n gi&#7919; primary context clean</p></li></ul><h4>Complete Example v&#7899;i All Options</h4><pre><code>{

  &#8220;command&#8221;: {

    &#8220;comprehensive-review&#8221;: {

      &#8220;description&#8221;: &#8220;Full code review with security analysis&#8221;,

      &#8220;template&#8221;: &#8220;Review these changes comprehensively:\n\n!`git diff main...HEAD`\n\nCheck for:\n- Security vulnerabilities\n- Performance issues\n- Code quality\n- Test coverage\n\nProvide actionable feedback.&#8221;,

      &#8220;agent&#8221;: &#8220;reviewer&#8221;,

      &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

      &#8220;subtask&#8221;: false

    }

  }

}</code></pre><div><hr></div><h3>Advanced Command Techniques</h3><h4>1. Arguments Handling</h4><p>T&#7841;o command linh ho&#7841;t v&#7899;i parameters:</p><p>.<code>opencode/command/component.md</code>:</p><pre><code>---

description: Create new React component with TypeScript

---

Create a new React component named $ARGUMENTS with TypeScript support.

Include proper typing and basic structure.

Place it in: src/components/$ARGUMENTS.tsx

Use this template:

```tsx

import React from &#8220;react&#8221;;

interface $ARGUMENTSProps {

  // Define props here

}

export const $ARGUMENTS: React.FC&lt;$ARGUMENTSProps&gt; = () =&gt; {

  return (

    &lt;div&gt;

      &lt;h1&gt;$ARGUMENTS Component&lt;/h1&gt;

    &lt;/div&gt;

  );

};

```</code></pre><blockquote><p><strong>Usage:</strong> <code>/component Button</code> &#8594; T&#7841;o Button component ho&#224;n ch&#7881;nh</p></blockquote><div class="pullquote"><p>V&#224; $ARGUMENTS s&#7869; &#273;&#432;&#7907;c thay th&#7871; b&#7857;ng Button.</p></div><h4>2. Positional Arguments</h4><p>Truy&#7873;n &#273;&#7889;i s&#7889; cho c&#225;c l&#7879;nh b&#7857;ng c&#225;ch s&#7917; d&#7909;ng tr&#236;nh gi&#7919; ch&#7895; $ARGUMENTS.</p><p><code>.opencode/command/create-file.md</code>:</p><pre><code>---

description: Create file with content in specific directory

---

Create a file named $1 in the directory $2 with the following content:

$3

Make sure the directory exists and use proper file extension.</code></pre><blockquote><p><strong>Usage:</strong> <code>/create-file config.json src &#8220;{ \&#8221;key\&#8221;: \&#8221;value\&#8221; }&#8221;</code></p></blockquote><div class="pullquote"><p>&#272;&#226;y thay th&#7871;:</p><ul><li><p><code>$1</code> v&#7899;i <code>config.json</code></p></li><li><p><code>$2</code> v&#7899;i <code>src</code></p></li><li><p><code>$3</code> v&#7899;i <code>{ &#8220;key&#8221;: &#8220;value&#8221; }</code></p></li></ul></div><h4>3. Shell Output Integration</h4><p>S&#7917; d&#7909;ng <code>!command</code> &#273;&#7875; &#273;&#432;a &#273;&#7847;u ra <a href="https://heyhuynhgiabuu.substack.com/p/opencode-tui-mastery-terminal-interface">l&#7879;nh bash</a> v&#224;o prompt c&#7911;a b&#7841;n.</p><p><code>.opencode/command/review-changes.md</code>:</p><pre><code>---

description: Review recent git changes

---

Review these recent changes and suggest improvements:

Recent commits:

!`git log --oneline -10`

Current changes:

!`git diff --name-only`

Diff details:

!`git diff`

Focus on:

- Code quality issues

- Potential bugs

- Performance concerns

- Security vulnerabilities</code></pre><div class="pullquote"><p>C&#225;c l&#7879;nh ch&#7841;y trong th&#432; m&#7909;c g&#7889;c c&#7911;a d&#7921; &#225;n v&#224; &#273;&#7847;u ra c&#7911;a ch&#250;ng tr&#7903; th&#224;nh m&#7897;t ph&#7847;n c&#7911;a prompt.</p></div><h4>4. File References</h4><p><code>.opencode/command/analyze-component.md</code>:</p><pre><code>---

description: Deep analyze component for performance issues

---

Analyze the component in @src/components/Button.tsx for:

- Performance bottlenecks

- Re-render optimization opportunities

- Bundle size impact

- Accessibility issues

Suggest specific improvements with code examples.</code></pre><div class="pullquote"><p>N&#7897;i dung t&#7879;p s&#7869; t&#7921; &#273;&#7897;ng &#273;&#432;&#7907;c &#273;&#432;a v&#224;o prompt.</p></div><h4>5. Override Built-in Commands</h4><p>OpenCode cho ph&#233;p b&#7841;n override built-in commands nh&#432; <code>/init</code>, <code>/undo</code>, <code>/redo</code>, <code>/share</code>, <code>/help</code>.</p><p><strong>V&#237; d&#7909;: Custom</strong><code> /init</code><strong> command</strong></p><p><code>.opencode/command/init.md</code>:</p><pre><code>---

description: Custom project initialization with team setup

---

Initialize project with team-specific settings:

1. Analyze project structure

2. Create team-standard AGENTS.md

3. Setup recommended commands

4. Configure project-specific tools

5. Generate onboarding checklist

Team standards:

- Use TypeScript strict mode

- ESLint + Prettier configuration

- Jest for testing

- Conventional commits

!`npm init -y` (if package.json doesn&#8217;t exist)

!`git init` (if not a git repo)</code></pre><blockquote><p><strong>&#9888;&#65039; C&#7849;n th&#7853;n khi override built-in commands:</strong></p><ul><li><p>Ch&#7881; override khi b&#7841;n th&#7921;c s&#7921; c&#7847;n custom behavior</p></li><li><p>Gi&#7919; l&#7841;i core functionality c&#7911;a original command</p></li><li><p>Document changes cho team</p></li></ul></blockquote><p><strong>V&#237; d&#7909;: Enhanced /help command</strong></p><p><code>.opencode/command/help.md:</code></p><pre><code>---

description: Custom help with team-specific commands

---

# OpenCode Help - Team Edition

## Built-in Commands

- `/init` - Initialize project (team version)

- `/undo` - Undo last change

- `/redo` - Redo undone change

- `/share` - Share conversation

## Team Custom Commands

- `/test` - Run tests with coverage analysis

- `/review` - Code review with team standards

- `/deploy` - Safe deployment workflow

- `/cleanup` - Project cleanup and optimization

## Getting Started

1. Run `/init` for project setup

2. Try `/test` to verify everything works

3. Use `/review` before committing changes

Need help? Ask in team Slack #opencode channel!</code></pre><div><hr></div><h3>10 Commands h&#7919;u &#237;ch nh&#7845;t cho daily work</h3><h4>1. Smart Test Runner</h4><pre><code>---

description: Run tests with intelligent failure analysis

---

!`npm test`

If any tests failed:

1. Analyze failure patterns

2. Identify root causes

3. Suggest specific fixes

4. Check if similar issues exist elsewhere</code></pre><h4>2. Code Review Assistant</h4><pre><code>---

description: Review PR changes like senior dev

---

Review these changes:

!`git diff main...HEAD`

Check for:

- Code quality and consistency

- Performance implications

- Security concerns

- Test coverage

- Documentation updates

Provide actionable feedback.</code></pre><h4>3. Dependency Updater</h4><pre><code>---

description: Check and update dependencies safely

---

Check for outdated packages:

!`npm outdated`

For each outdated dependency:

1. Check breaking changes

2. Update one by one

3. Run tests after each update

4. Rollback if tests fail

</code></pre><h4>4. Performance Profiler</h4><pre><code>---

description: Analyze bundle size and performance

---

Current bundle analysis:

!`npm run analyze`

Identify:

- Largest dependencies

- Unused code

- Optimization opportunities

- Lazy loading candidates</code></pre><h4>5. Security Scanner</h4><pre><code>---

description: Scan for security vulnerabilities

---

Run security audit:

!`npm audit`

For each vulnerability:

1. Assess severity

2. Check exploitability

3. Suggest remediation

4. Provide patch examples</code></pre><h4>6. Database Migration Helper</h4><pre><code>---

description: Safe database migration workflow

---

Current migration status:

!`npm run migrate:status`

Pending migrations:

!`npm run migrate:pending`

Plan:

1. Backup current database

2. Review migration files

3. Run migrations in staging

4. Execute in production

5. Verify data integrity</code></pre><h4>7. API Documentation Generator</h4><pre><code>---

description: Generate API docs from code

---

Analyze API routes:

!`find . -name &#8220;*.ts&#8221; -path &#8220;*/api/*&#8221; -exec grep -l &#8220;export.*\(Handler\|Route\)&#8221; {} \;`

Generate documentation for:

- Endpoints and methods

- Request/response schemas

- Authentication requirements

- Rate limiting info</code></pre><h4>8. Environment Setup Validator</h4><pre><code>---

description: Validate development environment

---

Check environment setup:

!`node --version &amp;&amp; npm --version &amp;&amp; git --version`

Verify:

- Required tools are installed

- Environment variables are set

- Dependencies are properly installed

- Configuration files are valid</code></pre><h4>9. Cleanup Assistant</h4><pre><code>---

description: Clean up project and optimize storage

---

Analyze project for cleanup:

!`find . -name &#8220;node_modules&#8221; -type d`

!`find . -name &#8220;*.log&#8221; -type f`

!`find . -name &#8220;.DS_Store&#8221; -type f`

Suggest:

- Unused dependencies to remove

- Cache directories to clean

- Temporary files to delete

- Disk space recovery opportunities</code></pre><h4>10. Release Preparation</h4><pre><code>---

description: Prepare for production release

---

Release checklist:

!`npm run test`

!`npm run build`

!`npm run lint`

Version info:

!`git describe --tags`

!`git log --oneline $(git describe --tags --abbrev=0)..HEAD`

Verify:

- All tests pass

- Build succeeds

- No linting errors

- Changelog is updated

- Version is bumped</code></pre><div><hr></div><h3>CLI Automation v&#7899;i OpenCode</h3><p>OpenCode CLI cho ph&#233;p b&#7841;n script v&#224; automate workflows:</p><h4>Basic CLI Usage</h4><pre><code># Quick question without TUI

opencode run &#8220;Explain how closures work in JavaScript&#8221;

# Use specific model

opencode run -m anthropic/claude-3-5-sonnet-20241022 &#8220;Review this code&#8221;

# Use specific agent

opencode run --agent reviewer &#8220;Check for security issues&#8221;

# Continue previous session

opencode run -c &#8220;Continue with the previous analysis&#8221;</code></pre><h4>Scripting Examples</h4><ul><li><p><strong>Automated Code Review Script:</strong></p></li></ul><pre><code>#!/bin/bash

# review-pr.sh

echo &#8220;&#128269; Analyzing PR changes...&#8221;

opencode run &#8220;

Review these changes for code quality:

$(git diff main...HEAD)

Focus on:

- Performance implications

- Security vulnerabilities

- Code consistency

- Test coverage

Provide specific, actionable feedback.

&#8220;</code></pre><ul><li><p><strong>Daily Health Check Script:</strong></p></li></ul><pre><code>#!/bin/bash

# daily-check.sh

echo &#8220;&#127973; Running daily health check...&#8221;

# Check dependencies

opencode run &#8220;

Check for security vulnerabilities:

$(npm audit)

Suggest immediate actions for any high-severity issues.

&#8220;

# Run tests

opencode run --agent build &#8220;

Run full test suite and analyze any failures:

$(npm test)

If tests fail, identify root causes and suggest fixes.

&#8220;</code></pre><h4>Batch Operations</h4><ul><li><p><strong>Multiple File Processing:</strong></p></li></ul><pre><code># Process all TypeScript files

for file in $(find src -name &#8220;*.ts&#8221;); do

    echo &#8220;Processing $file...&#8221;

    opencode run &#8220;Analyze $file for performance optimizations&#8221;

done</code></pre><ul><li><p><strong>Component Documentation:</strong></p></li></ul><pre><code># Generate docs for all components

for component in src/components/*; do

    name=$(basename &#8220;$component&#8221;)

    opencode run &#8220;

Generate documentation for $name component:

$(cat &#8220;$component&#8221;)

Include props, usage examples, and best practices.

&#8220; &gt; &#8220;docs/components/$name.md&#8221;

done</code></pre><div><hr></div><h4>Best Practices cho Commands</h4><h4>1. Quy &#432;&#7899;c &#273;&#7863;t t&#234;n</h4><ul><li><p>S&#7917; d&#7909;ng descriptive names: <code>test-with-coverage</code> thay v&#236; <code>twc</code></p></li><li><p>C&#225;c l&#7879;nh li&#234;n quan &#273;&#7871;n nh&#243;m: <code>test-*</code>, <code>deploy-*</code>, <code>review-*</code></p></li><li><p>S&#7917; d&#7909;ng kebab-case cho c&#225;c l&#7879;nh nhi&#7873;u t&#7915;</p></li></ul><h4>2. X&#7917; l&#253; l&#7895;i</h4><pre><code>---

description: Safe deployment with rollback

---

Try deployment:

!`npm run deploy`

If deployment fails:

1. Check error logs: !`kubectl logs deployment/app --tail=50`

2. Rollback to previous version: !`kubectl rollout undo deployment/app`

3. Verify rollback success: !`kubectl get pods`

4. Report specific failure reasons</code></pre><h4>3. T&#7889;i &#432;u h&#243;a hi&#7879;u su&#7845;t</h4><ul><li><p>S&#7917; d&#7909;ng c&#225;c agent c&#7909; th&#7875; cho c&#225;c task ph&#249; h&#7907;p</p></li><li><p>Gi&#7899;i h&#7841;n &#273;&#7847;u ra shell v&#7899;i th&#244;ng tin li&#234;n quan</p></li><li><p>Cache c&#225;c ho&#7841;t &#273;&#7897;ng &#273;&#7855;t ti&#7873;n khi c&#243; th&#7875;</p></li></ul><h4>4. C&#226;n nh&#7855;c v&#7873; b&#7843;o m&#7853;t</h4><ul><li><p>Kh&#244;ng bao gi&#7901; hardecode d&#7919; li&#7879;u nh&#7841;y c&#7843;m trong l&#7879;nh</p></li><li><p>S&#7917; d&#7909;ng bi&#7871;n m&#244;i tr&#432;&#7901;ng cho gi&#225; tr&#7883; b&#237; m&#7853;t</p></li><li><p>X&#225;c th&#7921;c &#273;&#7847;u v&#224;o trong c&#225;c l&#7879;nh t&#249;y ch&#7881;nh</p></li></ul><div><hr></div><h3>Team Workflow v&#7899;i Commands</h3><h4>Kho l&#432;u tr&#7919; l&#7879;nh chia s&#7867;</h4><p>T&#7841;o <code>.opencode/command/</code> directory trong project root v&#224; commit v&#224;o Git:</p><pre><code>.opencode/

&#9500;&#9472;&#9472; command/

&#9474;   &#9500;&#9472;&#9472; test.md

&#9474;   &#9500;&#9472;&#9472; review.md

&#9474;   &#9500;&#9472;&#9472; deploy.md

&#9474;   &#9492;&#9472;&#9472; cleanup.md

&#9492;&#9472;&#9472; config.json</code></pre><h4>Gi&#7899;i thi&#7879;u th&#224;nh vi&#234;n nh&#243;m m&#7899;i</h4><ol><li><p><strong>Setup Commands:</strong></p></li></ol><pre><code># Clone project

git clone &lt;repo&gt;

cd &lt;repo&gt;

# OpenCode s&#7869; t&#7921; &#273;&#7897;ng detect commands

opencode

/init</code></pre><ol start="2"><li><p><strong>Available Commands:</strong></p></li></ol><p>   G&#245; <code>/</code> &#273;&#7875; see all available commands v&#7899;i descriptions</p><ol start="3"><li><p><strong>Team Standards:</strong></p></li></ol><p>   Commands enforce consistent workflows across team</p><h4>M&#7851;u l&#7879;nh cho c&#225;c lo&#7841;i d&#7921; &#225;n kh&#225;c nhau</h4><ul><li><p><strong>React Project Commands:</strong></p></li></ul><pre><code># component.md

Create React component with TypeScript and tests

# story.md

Generate Storybook story for component

# test.md

Run Jest tests with coverage</code></pre><ul><li><p><strong>Node.js API Commands:</strong></p></li></ul><pre><code># endpoint.md

Create new API endpoint with validation

# migrate.md

Run database migrations safely

# seed.md

Seed database with test data</code></pre><ul><li><p><strong>Python Project Commands:</strong></p></li></ul><pre><code># test.md

Run pytest with coverage

# lint.md

Run black, flake8, mypy

# requirements.md

Update requirements.txt safely</code></pre><div><hr></div><h3>Kh&#7855;c ph&#7909;c s&#7921; c&#7889; th&#432;&#7901;ng g&#7863;p</h3><h4>L&#7879;nh kh&#244;ng t&#236;m th&#7845;y</h4><pre><code># Check command files exist

ls -la .opencode/command/

# Verify syntax

opencode run &#8220;Check my command syntax&#8221;</code></pre><h4>L&#7879;nh Shell kh&#244;ng th&#224;nh c&#244;ng</h4><pre><code>---

description: Debug shell command

---

Debug this command:

!`failing-command`

Check:

1. Command exists in PATH

2. Required permissions

3. Working directory

4. Environment variables</code></pre><h4>&#272;&#7889;i s&#7889; kh&#244;ng ho&#7841;t &#273;&#7897;ng</h4><pre><code>---

description: Test argument handling

---

Testing arguments:

- All arguments: $ARGUMENTS

- First argument: $1

- Second argument: $2

Debug argument parsing issues.</code></pre><div><hr></div><h3>Measuring ROI c&#7911;a Commands</h3><h4>Before Commands:</h4><ul><li><p>Manual test running: 5 minutes &#215; 10 times/day = 50 minutes</p></li><li><p>Code review setup: 10 minutes &#215; 5 PRs/day = 50 minutes</p></li><li><p>Deployment process: 15 minutes &#215; 3 deployments/day = 45 minutes</p></li></ul><blockquote><p> <strong>Total: 145 minutes/day</strong></p></blockquote><h4>After Commands:</h4><ul><li><p><code>/test</code>: 30 seconds &#215; 10 = 5 minutes</p></li><li><p><code>/review</code>: 2 minutes &#215; 5 PRs = 10 minutes</p></li><li><p><code>/deploy</code>: 3 minutes &#215; 3 = 9 minutes</p></li></ul><blockquote><p><strong>Total: 24 minutes/day</strong></p></blockquote><div class="pullquote"><p><strong>Time saved: 121 minutes/day = 2 hours/day = 10 hours/week</strong></p></div><div><hr></div><h3>Next Steps: Code Quality &amp; Team Standards</h3><p>Commands l&#224; foundation cho automation. Trong b&#224;i ti&#7871;p theo, ch&#250;ng ta s&#7869; kh&#225;m ph&#225; <strong>Code Quality: Formatters &amp; Rules chu&#7849;n team</strong> - c&#225;ch &#273;&#7843;m b&#7843;o code consistency across entire team.</p><p>B&#7841;n s&#7869; h&#7885;c &#273;&#432;&#7907;c:</p><ul><li><p>Auto-formatting v&#7899;i Prettier, ESLint</p></li><li><p>Custom formatters cho specific needs</p></li><li><p>Team rules v&#224; guidelines</p></li><li><p>Git hooks integration</p></li></ul><div><hr></div><h2>Exercise cho b&#7841;n</h2><ol><li><p><strong>T&#7841;o 3 commands cho project c&#7911;a b&#7841;n:</strong></p></li></ol><ul><li><p>M&#7897;t command cho testing</p></li><li><p>M&#7897;t command cho code review</p></li><li><p>M&#7897;t command cho deployment</p></li></ul><ol start="2"><li><p><strong>Share commands v&#7899;i team:</strong></p></li></ol><ul><li><p>Commit <code>.opencode/command/</code> v&#224;o Git</p></li><li><p>Document usage trong team wiki</p></li></ul><ol start="3"><li><p><strong>Measure time saved:</strong></p></li></ol><ul><li><p>Track time tr&#432;&#7899;c v&#224; sau khi d&#249;ng commands</p></li><li><p>Share results v&#7899;i team</p></li></ul><blockquote><p><strong>Comment below:</strong> Commands b&#7841;n t&#7841;o v&#224; k&#7871;t qu&#7843; time saved! C&#249;ng nhau h&#7885;c h&#7887;i nh&#233;! &#128170;</p></blockquote><div><hr></div><p>_&#272;&#226;y l&#224; b&#224;i 5 trong series &#8220;<strong>H&#224;nh Tr&#236;nh L&#7853;p Tr&#236;nh v&#7899;i Opencode</strong>&#8221;. &#272;&#7885;c c&#225;c b&#224;i tr&#432;&#7899;c t&#7841;i [<a href="https://heyhuynhgiabuu.substack.com/">series overview</a>]._</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Dev k&#7875; chuy&#7879;n th&#7853;t, chia s&#7867; b&#237; k&#237;p s&#7889;ng s&#243;t v&#224; ki&#7871;n th&#7913;c m&#7899;i<strong> &#8211; &#273;&#259;ng k&#253; &#273;&#7875; kh&#244;ng l&#7841;c h&#7853;u!</strong></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[OpenCode TUI mastery: Terminal interface cho senior dev]]></title><description><![CDATA[Master TUI - Giao di&#7879;n terminal ho&#224;n h&#7843;o cho senior dev]]></description><link>https://heyhuynhgiabuu.substack.com/p/opencode-tui-mastery-terminal-interface</link><guid isPermaLink="false">https://heyhuynhgiabuu.substack.com/p/opencode-tui-mastery-terminal-interface</guid><dc:creator><![CDATA[Huynh Gia Buu]]></dc:creator><pubDate>Thu, 30 Oct 2025 18:59:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!NfoU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>Khi terminal c&#7911;a b&#7841;n &#273;ang &#8220;l&#227;ng ph&#237;&#8221; 90% kh&#7843; n&#259;ng</h3><p>T&#244;i &#273;&#227; ch&#7913;ng ki&#7871;n h&#224;ng tr&#259;m developer Vi&#7879;t Nam d&#249;ng OpenCode v&#7899;i <strong>default terminal</strong>, v&#224; h&#7885; &#273;ang b&#7887; l&#7905; 90% s&#7913;c m&#7841;nh.</p><p>C&#243; developer h&#7887;i t&#244;i: &#8220;Sao anh d&#249;ng OpenCode nhanh th&#7871;? Em c&#361;ng d&#249;ng m&#224; th&#7845;y ch&#7853;m qu&#225;.&#8221;</p><p>T&#244;i h&#7887;i l&#7841;i: &#8220;B&#7841;n &#273;ang d&#249;ng terminal g&#236;?&#8221;</p><p>&#8220;Terminal m&#7863;c &#273;&#7883;nh c&#7911;a Mac &#7841;.&#8221;</p><p>**V&#7845;n &#273;&#7873; &#7903; &#273;&#226;y:** Kh&#244;ng ph&#7843;i OpenCode ch&#7853;m, m&#224; terminal b&#7841;n &#273;ang d&#249;ng ch&#432;a &#273;&#432;&#7907;c optimize.</p><p>H&#244;m nay, t&#244;i s&#7869; d&#7841;y b&#7841;n bi&#7871;n terminal th&#432;&#7901;ng th&#224;nh <strong>workstation chuy&#234;n nghi&#7879;p</strong> ch&#7881; trong 15 ph&#250;t. Kh&#244;ng c&#7847;n mua IDE &#273;&#7855;t ti&#7873;n, kh&#244;ng c&#7847;n h&#7885;c 50 shortcut ph&#7913;c t&#7841;p.</p><p></p><h3>1. Hi&#7875;u &#273;&#250;ng: TUI c&#7911;a OpenCode l&#224; g&#236;?</h3><h4>A. TUI vs CLI - Kh&#225;c bi&#7879;t c&#417; b&#7843;n</h4><ul><li><p><strong>CLI (Command Line Interface):</strong></p></li></ul><pre><code>opencode run &#8220;What models are available&#8221;</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NfoU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NfoU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 424w, https://substackcdn.com/image/fetch/$s_!NfoU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 848w, https://substackcdn.com/image/fetch/$s_!NfoU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 1272w, https://substackcdn.com/image/fetch/$s_!NfoU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NfoU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:691671,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://heyhuynhgiabuu.substack.com/i/177590210?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NfoU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 424w, https://substackcdn.com/image/fetch/$s_!NfoU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 848w, https://substackcdn.com/image/fetch/$s_!NfoU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 1272w, https://substackcdn.com/image/fetch/$s_!NfoU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb515acc6-30ec-4a05-8d8f-9a4669a54d6f_5120x2880.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p><strong>TUI (Terminal User Interface):</strong></p></li></ul><pre><code>opencode  # M&#7903; giao di&#7879;n t&#432;&#417;ng t&#225;c</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gZAC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gZAC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 424w, https://substackcdn.com/image/fetch/$s_!gZAC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 848w, https://substackcdn.com/image/fetch/$s_!gZAC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 1272w, https://substackcdn.com/image/fetch/$s_!gZAC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gZAC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/affa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:629767,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://heyhuynhgiabuu.substack.com/i/177590210?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gZAC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 424w, https://substackcdn.com/image/fetch/$s_!gZAC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 848w, https://substackcdn.com/image/fetch/$s_!gZAC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 1272w, https://substackcdn.com/image/fetch/$s_!gZAC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faffa37fb-bf03-4ee4-944e-d239f7a24389_5120x2880.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>T&#7841;i sao TUI quan tr&#7885;ng?</strong></p><ul><li><p>Giao di&#7879;n visual gi&#250;p b&#7841;n th&#7845;y r&#245; conversation flow</p></li><li><p>Multi-pane layout cho debugging hi&#7879;u qu&#7843;</p></li><li><p>Real-time interaction v&#7899;i AI</p></li><li><p>Context switching nhanh gi&#7919;a c&#225;c tasks</p></li></ul><h4>B. Built-in commands trong TUI (Theo docs ch&#237;nh th&#7913;c)</h4><p>OpenCode cung c&#7845;p h&#417;n 20 commands trong TUI:</p><ul><li><p><strong>Navigation commands:</strong></p><ul><li><p><code>/models</code> - Xem danh s&#225;ch models (Ctrl+X M)</p></li><li><p><code>/themes</code> - Ch&#7885;n theme (Ctrl+X T)</p></li><li><p><code>/sessions</code> - Switch gi&#7919;a sessions (Ctrl+X L)</p></li></ul></li><li><p><strong>Session management:</strong></p><ul><li><p><code>/new</code> - B&#7855;t &#273;&#7847;u session m&#7899;i (Ctrl+X N)</p></li><li><p><code>/undo</code> - Ho&#224;n t&#225;c thay &#273;&#7893;i (Ctrl+X U)</p></li><li><p><code>/redo</code> - L&#224;m l&#7841;i (Ctrl+X R)</p></li><li><p><code>/export</code> - Export conversation (Ctrl+X X)</p></li></ul></li><li><p><strong>Development tools:</strong></p><ul><li><p><code>/editor</code> - M&#7903; external editor (Ctrl+X E)</p></li><li><p><code>/init</code> - Update AGENTS.md (Ctrl+X I)</p></li><li><p><code>/details</code> - Toggle tool details (Ctrl+X D)</p></li></ul></li></ul><p></p><h3>2. Setup terminal chu&#7849;n senior dev</h3><h4>A. Terminal requirements (Theo docs)</h4><p><strong>Truecolor support b&#7855;t bu&#7897;c:</strong></p><pre><code># Ki&#7875;m tra terminal b&#7841;n

echo $COLORTERM

# K&#7871;t qu&#7843;: truecolor ho&#7863;c 24bit</code></pre><p><strong>N&#7871;u kh&#244;ng c&#243; truecolor:</strong></p><pre><code># Th&#234;m v&#224;o ~/.zshrc ho&#7863;c ~/.bashrc

export COLORTERM=truecolor</code></pre><p><strong>Recommended terminals:</strong></p><ul><li><p><strong>Mac:</strong> iTerm2, Alacritty, WezTerm</p></li><li><p><strong>Linux:</strong> Alacritty, Kitty, GNOME Terminal</p></li><li><p><strong>Windows:</strong> Windows Terminal, WezTerm</p></li></ul><h4>B. T&#7889;i &#432;u scroll speed (Theo docs)</h4><p>OpenCode cho ph&#233;p &#273;i&#7873;u ch&#7881;nh scroll speed trong config:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;tui&#8221;: {

    &#8220;scroll_speed&#8221;: 3

  }

}</code></pre><p><strong>Gi&#7843;i th&#237;ch:</strong></p><ul><li><p><code>1</code>: Ch&#7853;m, ph&#249; h&#7907;p debug chi ti&#7871;t</p></li><li><p><code>2</code>: Default, balanced</p></li><li><p><code>3</code>: Nhanh, ph&#249; h&#7907;p code review</p></li><li><p><code>4</code>: R&#7845;t nhanh, cho power users</p></li></ul><p></p><h3>3. Themes &amp; Visual Customization</h3><h4>A. Built-in themes (Theo docs)</h4><p>OpenCode c&#243; 15+ themes built-in:</p><p><strong>Popular themes:</strong></p><ul><li><p><code>opencode</code> - Default theme c&#7911;a OpenCode</p></li><li><p><code>tokyonight</code> - Dark blue, ph&#7893; bi&#7871;n v&#7899;i dev Vi&#7879;t</p></li><li><p><code>everforest</code> - Green earthy tones</p></li><li><p><code>catppuccin</code> - Pastel colors, d&#7877; nh&#236;n</p></li><li><p><code>gruvbox</code> - Retro groove colors</p></li><li><p><code>nord</code> - Arctic blue tones</p></li></ul><p><strong>Special themes:</strong></p><ul><li><p><code>system</code> - T&#7921; &#273;&#7897;ng adapt theo terminal</p></li><li><p><code>matrix</code> - Hacker style green-on-black</p></li></ul><h4>B. Ch&#7885;n theme nhanh</h4><pre><code># Trong OpenCode TUI

/themes

# Ho&#7863;c trong config

{

  &#8220;theme&#8221;: &#8220;tokyonight&#8221;

}</code></pre><h4>C. Custom themes (Advanced)</h4><p>T&#7841;o theme ri&#234;ng trong <code>~/.config/opencode/themes/my-theme.json</code>:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/theme.json&#8221;,

  &#8220;theme&#8221;: {

    &#8220;primary&#8221;: { &#8220;dark&#8221;: &#8220;#00ff00&#8221;, &#8220;light&#8221;: &#8220;#008800&#8221; },

    &#8220;background&#8221;: { &#8220;dark&#8221;: &#8220;#000000&#8221;, &#8220;light&#8221;: &#8220;#ffffff&#8221; },

    &#8220;text&#8221;: { &#8220;dark&#8221;: &#8220;#ffffff&#8221;, &#8220;light&#8221;: &#8220;#000000&#8221; }

  }

}</code></pre><p></p><h4>4. Keybinds Optimization</h4><h4>A. Leader key system (Theo docs)</h4><p>OpenCode d&#249;ng <strong>leader key</strong> &#273;&#7875; tr&#225;nh conflict:</p><ul><li><p>Default: `Ctrl+X`</p></li><li><p>Sau &#273;&#243; nh&#7845;n ph&#237;m ch&#7913;c n&#259;ng</p></li></ul><p><strong>V&#237; d&#7909; workflow:</strong></p><ol><li><p><code>Ctrl+X</code> (leader)</p></li><li><p><code>M</code> (models)</p></li><li><p>Ch&#7885;n model t&#7915; list</p></li></ol><h4>B. Essential keybinds cho daily work</h4><ul><li><p><strong>Navigation nhanh:</strong></p><ul><li><p><code>Ctrl+X M</code> - Models list</p></li><li><p><code>Ctrl+X T</code> - Themes</p></li><li><p><code>Ctrl+X L</code> - Sessions</p></li></ul></li><li><p><strong>Session management:</strong></p><ul><li><p><code>Ctrl+X N</code> - New session</p></li><li><p><code>Ctrl+X U</code> - Undo changes</p></li><li><p><code>Ctrl+X R</code> - Redo</p></li><li><p><code>Ctrl+X X</code> - Export</p></li></ul></li><li><p><strong>Development tools:</strong></p><ul><li><p><code>Ctrl+X E</code> - External editor</p></li><li><p><code>Ctrl+X I</code> - Init project</p></li><li><p><code>Ctrl+X D</code> - Toggle details</p></li></ul></li></ul><h4>C. Custom keybinds trong config</h4><pre><code>{

  &#8220;keybinds&#8221;: {

    &#8220;leader&#8221;: &#8220;ctrl+x&#8221;,

    &#8220;model_list&#8221;: &#8220;ctrl+x m&#8221;,

    &#8220;theme_list&#8221;: &#8220;ctrl+x t&#8221;,

    &#8220;session_new&#8221;: &#8220;ctrl+x n&#8221;

  }

}</code></pre><p></p><h3>5. Focus Mode cho Deep Work</h3><p><strong>K&#237;ch ho&#7841;t focus mode v&#7899;i theme ph&#249; h&#7907;p</strong>:</p><pre><code>{

  &#8220;theme&#8221;: &#8220;matrix&#8221;, // Hacker theme

  &#8220;tui&#8221;: {

    &#8220;scroll_speed&#8221;: 1 // Slow, deliberate

  }

}</code></pre><p><strong>Workflow focus mode:</strong></p><ol><li><p>Ch&#7885;n theme t&#7889;i (matrix, tokyonight)</p></li><li><p>Gi&#7843;m scroll speed xu&#7889;ng 1</p></li><li><p>T&#7855;t notifications ngo&#224;i</p></li><li><p>Full screen terminal</p></li><li><p>Single task focus</p></li></ol><p></p><h3>6. Performance Optimization</h3><h4>A. Terminal performance tuning</h4><ul><li><p><strong>iTerm2:</strong></p></li></ul><pre><code># Preferences &gt; Profiles &gt; Terminal

- Unlimited scrollback

- Enable mouse reporting

- Use built-in powerline glyphs</code></pre><ul><li><p><strong>Alacritty :</strong></p></li></ul><pre><code># ~/.config/alacritty/alacritty.yml

scrolling:

  history: 100000

  multiplier: 3

font:

  size: 14.0

  normal:

    family: &#8220;Fira Code&#8221;

</code></pre><h4>B. Memory v&#224; CPU optimization</h4><ul><li><p><strong>Large projects:</strong></p><ul><li><p>D&#249;ng `/compact` &#273;&#7875; summarize sessions</p></li><li><p>Limit scrollback history</p></li><li><p>Disable animations n&#7871;u c&#7847;n</p></li></ul></li><li><p><strong>Multi-session workflow:</strong></p><ul><li><p>Switch sessions thay v&#236; duplicate</p></li><li><p>Export old sessions &#273;&#7875; archive</p></li><li><p>Use `/new` cho clean state</p></li></ul></li></ul><p></p><h3>7. Real-world Workflows</h3><h4>A. Daily development workflow</h4><p><strong>Morning setup (2 ph&#250;t):</strong></p><ol><li><p>M&#7903; terminal</p></li><li><p><code>opencode</code> &#8594; v&#224;o project</p></li><li><p><code>/models</code> &#8594; ch&#7885;n model ph&#249; h&#7907;p</p></li><li><p><code>/themes</code> &#8594; ch&#7885;n theme theo mood</p></li></ol><p><strong>Coding session:</strong></p><ol><li><p><code>Ctrl+X E</code> &#8594; m&#7903; external editor</p></li><li><p>Code v&#7899;i AI assistance</p></li><li><p><code>Ctrl+X U</code> &#8594; undo n&#7871;u c&#7847;n</p></li><li><p><code>Ctrl+X X</code> &#8594; export khi xong</p></li></ol><h4>B. Code review workflow</h4><p><strong>Review mode:</strong></p><ol><li><p><code>/themes</code> &#8594; ch&#7885;n theme s&#225;ng (d&#7877; &#273;&#7885;c)</p></li><li><p><code>/details</code> &#8594; b&#7853;t tool details</p></li><li><p>Review code v&#7899;i AI</p></li><li><p>Export recommendations</p></li></ol><h4>C. Debugging workflow</h4><p><strong>Debug mode:</strong></p><ol><li><p>Focus mode v&#7899;i theme t&#7889;i</p></li><li><p>Multi-pane layout</p></li><li><p>Step-through v&#7899;i AI</p></li><li><p>Document findings</p></li></ol><p></p><h3>8. Common TUI Mistakes</h3><h4>1. Terminal kh&#244;ng h&#7895; tr&#7907; truecolor</h4><blockquote><p><strong>Sai:</strong> D&#249;ng default Terminal.app tr&#234;n Mac c&#361;</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> Upgrade l&#234;n iTerm2 ho&#7863;c Alacritty</p></div><h4>2. Scroll speed qu&#225; nhanh</h4><blockquote><p><strong>Sai:</strong> &#272;&#7875; default speed cho m&#7885;i task</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> &#272;i&#7873;u ch&#7881;nh theo task: 1 cho debug, 3 cho review</p></div><h4>3. Kh&#244;ng d&#249;ng keybinds</h4><blockquote><p><strong>Sai:</strong> Ch&#7881; d&#249;ng mouse v&#224; commands</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> H&#7885;c 10 keybinds essential &#273;&#7875; t&#259;ng t&#7889;c</p></div><h4>4. Theme kh&#244;ng ph&#249; h&#7907;p</h4><blockquote><p><strong>Sai:</strong> D&#249;ng theme m&#7863;c &#273;&#7883;nh cho m&#7885;i ho&#224;n c&#7843;nh</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> Dark cho coding, light cho review, focus mode cho deep work</p></div><p></p><h3>9. K&#7871;t lu&#7853;n: B&#7841;n &#273;&#227; c&#243; workstation chuy&#234;n nghi&#7879;p</h3><p>Sau b&#224;i n&#224;y, b&#7841;n c&#243;:</p><p>&#9989; <strong>Terminal optimized</strong> - Truecolor, performance, layout</p><p>&#9989; <strong>TUI mastery</strong> - Commands, keybinds, themes</p><p>&#9989; <strong>Workflow chu&#7849;n</strong> - Daily, review, debug modes</p><p>&#9989; <strong>Focus mode</strong> - Deep work capability</p><p>&#9989; <strong>Productivity t&#259;ng</strong> - 3x faster interaction</p><blockquote><p><strong>Challenge:</strong> Setup TUI theo h&#432;&#7899;ng d&#7851;n, sau &#273;&#243; d&#249;ng 1 tu&#7847;n. Note l&#7841;i:</p></blockquote><ul><li><p>Theme n&#224;o b&#7841;n th&#237;ch nh&#7845;t?</p></li><li><p>Keybind n&#224;o ti&#7871;t ki&#7879;m th&#7901;i gian nh&#7845;t?</p></li><li><p>Focus mode c&#243; gi&#250;p b&#7841;n t&#7853;p trung kh&#244;ng?</p></li></ul><p><strong>Next step:</strong> Trong b&#224;i 5, t&#244;i s&#7869; d&#7841;y b&#7841;n Commands &amp; Automation - t&#7921; &#273;&#7897;ng ho&#225; m&#7885;i th&#7913; v&#7899;i custom commands. B&#7841;n s&#7869; th&#7845;y c&#225;ch bi&#7871;n 80% c&#244;ng vi&#7879;c l&#7863;p &#273;i l&#7863;p l&#7841;i th&#224;nh 5 ph&#250;t setup!</p><div><hr></div><p><strong>Homework:</strong> Th&#7917; 3 themes kh&#225;c nhau trong 3 ng&#224;y, sau &#273;&#243; ch&#7885;n theme ph&#249; h&#7907;p nh&#7845;t. Test focus mode v&#7899;i scroll_speed = 1. Share screenshots &#273;&#7875; c&#249;ng discuss!</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Dev k&#7875; chuy&#7879;n th&#7853;t, chia s&#7867; b&#237; k&#237;p s&#7889;ng s&#243;t v&#224; ki&#7871;n th&#7913;c m&#7899;i<strong> &#8211; &#273;&#259;ng k&#253; &#273;&#7875; kh&#244;ng l&#7841;c h&#7853;u!</strong></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Hướng dẫn config OpenCode từ A-Z cho người mới bắt đầu]]></title><description><![CDATA[Config OpenCode nh&#432; senior - 15 ph&#250;t setup &#273;&#7875; d&#249;ng 1 n&#259;m kh&#244;ng ph&#7843;i s&#7917;a]]></description><link>https://heyhuynhgiabuu.substack.com/p/huong-dan-config-opencode-tu-a-z</link><guid isPermaLink="false">https://heyhuynhgiabuu.substack.com/p/huong-dan-config-opencode-tu-a-z</guid><dc:creator><![CDATA[Huynh Gia Buu]]></dc:creator><pubDate>Wed, 29 Oct 2025 18:55:03 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/cd20f460-7f94-455c-903b-25e5520a1588_2526x1686.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>Khi developer m&#7845;t 30 ph&#250;t m&#7895;i ng&#224;y v&#236; config kh&#244;ng chu&#7849;n</h3><p>C&#243; m&#7897;t s&#7921; th&#7853;t &#273;au l&#242;ng: </p><div class="pullquote"><p><strong>90% developer Vi&#7879;t Nam &#273;ang config OpenCode sai c&#225;ch.</strong></p></div><p>T&#244;i &#273;&#227; ch&#7913;ng ki&#7871;n c&#7843;nh t&#432;&#7907;ng n&#224;y h&#224;ng tr&#259;m l&#7847;n:</p><ul><li><p>Developer A: M&#7895;i l&#7847;n &#273;&#7893;i project, m&#7845;t 30 ph&#250;t setup l&#7841;i t&#7915; &#273;&#7847;u</p></li><li><p>Developer B: Team 5 ng&#432;&#7901;i, 5 c&#225;ch config kh&#225;c nhau, kh&#244;ng ai hi&#7875;u ai</p></li><li><p>Developer C: AI xo&#225; nh&#7847;m file quan tr&#7885;ng v&#236; permission kh&#244;ng ch&#7863;t</p></li><li><p>Developer D: M&#7895;i th&#225;ng t&#7889;n th&#234;m 500k v&#236; d&#249;ng model &#273;&#7855;t cho task nh&#7865;</p></li></ul><blockquote><p>T&#7845;t c&#7843; &#273;&#7873;u c&#243; chung m&#7897;t nguy&#234;n nh&#226;n: <strong>Kh&#244;ng hi&#7875;u c&#225;ch config &#273;&#250;ng t&#7915; &#273;&#7847;u.</strong></p></blockquote><p>H&#244;m nay, t&#244;i s&#7869; d&#7841;y b&#7841;n config OpenCode nh&#432; senior dev th&#7921;c th&#7909;. Kh&#244;ng theory r&#432;&#7901;m r&#224;, ch&#7881; c&#243; <strong>15 ph&#250;t setup &#8594; d&#249;ng 1 n&#259;m kh&#244;ng ph&#7843;i s&#7917;a</strong>.</p><p></p><h3>1. Hi&#7875;u &#273;&#250;ng: OpenCode config system ho&#7841;t &#273;&#7897;ng th&#7871; n&#224;o?</h3><h4>A. C&#7845;u tr&#250;c c&#417; b&#7843;n (Theo docs ch&#237;nh th&#7913;c)</h4><p>OpenCode h&#7895; tr&#7907; <code>JSON </code>v&#224;<code> JSONC</code> (JSON with Comments). Lu&#244;n b&#7855;t &#273;&#7847;u v&#7899;i schema:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;

}</code></pre><p><strong>T&#7841;i sao c&#7847;n schema?</strong></p><ul><li><p>Editor t&#7921; &#273;&#7897;ng validate v&#224; g&#7907;i &#253;</p></li><li><p>Tr&#225;nh l&#7895;i syntax ph&#7893; bi&#7871;n</p></li><li><p>Lu&#244;n c&#7853;p nh&#7853;t v&#7899;i features m&#7899;i nh&#7845;t</p></li></ul><h4>B. V&#7883; tr&#237; config files (Priority order ch&#237;nh x&#225;c)</h4><p>Theo <a href="https://opencode.ai/docs/config/#locations">docs ch&#237;nh th&#7913;c</a>, OpenCode t&#236;m config theo th&#7913; t&#7921;:</p><ol><li><p><strong>Custom path</strong> (<code>OPENCODE_CONFIG</code> env var) - Cao nh&#7845;t</p></li><li><p><strong>Project config</strong> (<code>./opencode.json</code>) - Override global</p></li><li><p><strong>Global config</strong> (<code>~/.config/opencode/opencode.json</code>) - Foundation</p></li><li><p><strong>Custom directory</strong> (<code>OPENCODE_CONFIG_DIR</code>) - Extension</p></li></ol><blockquote><p><strong>Th&#7921;c t&#7871;:</strong> 90% th&#7901;i gian b&#7841;n ch&#7881; c&#7847;n quan t&#226;m &#273;&#7871;n <strong>Global + Project config</strong>.</p></blockquote><p></p><h3>2. C&#225;c kh&#243;a c&#7845;u h&#236;nh thi&#7871;t y&#7871;u (Copy-paste &#273;&#432;&#7907;c ngay)</h3><h4>A. Model &amp; Provider Configuration (Theo docs 2025)</h4><p><strong>Option 1: OpenCode Zen (Recommend cho ng&#432;&#7901;i m&#7899;i)</strong></p><pre><code>{

  &#8220;model&#8221;: &#8220;opencode/qwen3-coder-32b&#8221;,

  &#8220;provider&#8221;: {

    &#8220;opencode&#8221;: {

      &#8220;models&#8221;: {

        &#8220;qwen3-coder-32b&#8221;: {

          &#8220;name&#8221;: &#8220;Qwen 3 Coder (Recommended)&#8221;

        }

      }

    }

  }

}

```</code></pre><p><strong>Option 2: Claude Pro (T&#7889;t nh&#7845;t cho dev)</strong></p><pre><code>{

  &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

  &#8220;small_model&#8221;: &#8220;anthropic/claude-3-5-haiku-20241022&#8221;,

  &#8220;provider&#8221;: {

    &#8220;anthropic&#8221;: {

      &#8220;models&#8221;: {

        &#8220;claude-3-5-sonnet-20241022&#8221;: {

          &#8220;name&#8221;: &#8220;Claude 3.5 Sonnet&#8221;

        },

        &#8220;claude-3-5-haiku-20241022&#8221;: {

          &#8220;name&#8221;: &#8220;Claude 3.5 Haiku (Fast &amp; Cheap)&#8221;

        }

      }

    }

  }

}</code></pre><p><strong>Gi&#7843;i th&#237;ch t&#7915;ng th&#224;nh ph&#7847;n:</strong></p><ul><li><p><code>model</code>: AI ch&#237;nh cho tasks n&#7863;ng (code generation, analysis)</p></li><li><p><code>small_model</code>: AI ph&#7909; cho tasks nh&#7865; (title generation, quick questions) - <strong>Ti&#7871;t ki&#7879;m 70% chi ph&#237;</strong></p></li><li><p><code>provider</code>: C&#7845;u h&#236;nh authentication v&#224; models</p></li></ul><h4>B. Security &amp; Permission Settings (Kh&#244;ng &#273;&#432;&#7907;c b&#7887; qua)</h4><ul><li><p><strong>Permission levels theo docs:</strong> <code>&#8221;ask&#8221;</code>, <code>&#8221;auto&#8221;</code>, <code>&#8221;disabled&#8221;</code></p></li><li><p><strong>Config an to&#224;n cho team:</strong>*</p></li></ul><pre><code>{

  &#8220;permission&#8221;: {

    &#8220;write&#8221;: &#8220;ask&#8221;,

    &#8220;edit&#8221;: &#8220;ask&#8221;,

    &#8220;bash&#8221;: &#8220;ask&#8221;,

    &#8220;delete&#8221;: &#8220;ask&#8221;

  }

}</code></pre><ul><li><p><strong>Disable tools nguy hi&#7875;m:</strong></p></li></ul><pre><code>{

  &#8220;tools&#8221;: {

    &#8220;write&#8221;: true,

    &#8220;edit&#8221;: true,

    &#8220;bash&#8221;: false,

    &#8220;delete&#8221;: false

  }

}</code></pre><h4>C. TUI &amp; User Experience Optimization</h4><ul><li><p><strong>Scroll speed (theo docs):</strong></p></li></ul><pre><code>{

  &#8220;tui&#8221;: {

    &#8220;scroll_speed&#8221;: 2

  }

}</code></pre><ul><li><p><strong>Theme selection:</strong></p></li></ul><pre><code>{

  &#8220;theme&#8221;: &#8220;opencode&#8221; // Options: &#8220;opencode&#8221;, &#8220;system&#8221;, &#8220;aura&#8221;, &#8220;ayu&#8221;, &#8220;catppuccin&#8221;, "tokyonight"

}</code></pre><h4>D. Advanced Features (Optional nh&#432;ng powerful)</h4><ul><li><p><strong>Custom agents (specialized AI assistants):</strong></p></li></ul><pre><code>{

  &#8220;agent&#8221;: {

    &#8220;code-reviewer&#8221;: {

      &#8220;description&#8221;: &#8220;Reviews code for security and best practices&#8221;,

      &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

      &#8220;prompt&#8221;: &#8220;You are a senior code reviewer. Focus on security vulnerabilities, performance issues, and maintainability. Be constructive.&#8221;,

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: false,

        &#8220;edit&#8221;: false

      }

    }

  }

}</code></pre><ul><li><p><strong>Command templates (t&#7921; &#273;&#7897;ng ho&#225; tasks):</strong></p></li></ul><pre><code>{

  &#8220;command&#8221;: {

    &#8220;component&#8221;: {

      &#8220;template&#8221;: &#8220;Create React component named $ARGUMENTS with TypeScript, proper props typing, and basic tests&#8221;,

      &#8220;description&#8221;: &#8220;Create React component&#8221;

    }

  }

}</code></pre><p></p><h3>3. Environment Variables &amp; Dynamic Config (Pro tip)</h3><h4>A. Env Variable Substitution</h4><ul><li><p><strong>Gi&#7919; API keys an to&#224;n:</strong></p></li></ul><pre><code>{

  &#8220;provider&#8221;: {

    &#8220;anthropic&#8221;: {

      &#8220;options&#8221;: {

        &#8220;apiKey&#8221;: &#8220;{env:ANTHROPIC_API_KEY}&#8221;

      }

    }

  }

}</code></pre><ul><li><p><strong>Setup:</strong></p></li></ul><pre><code># Th&#234;m v&#224;o ~/.bashrc ho&#7863;c ~/.zshrc

export ANTHROPIC_API_KEY=&#8221;sk-ant-your-key-here&#8221;</code></pre><h4>B. File Include System</h4><ul><li><p><strong>Include instructions t&#7915; file:</strong></p></li></ul><pre><code>{

  &#8220;instructions&#8221;: [

    &#8220;{file:CONTRIBUTING.md}&#8221;,

    &#8220;{file:docs/team-guidelines.md}&#8221;,

    &#8220;{file:~/.config/opencode/global-instructions.md}&#8221;

  ]

}</code></pre><blockquote><p><strong>Best practice:</strong> Gi&#7919; secrets trong file ri&#234;ng:</p></blockquote><pre><code>{

  &#8220;provider&#8221;: {

    &#8220;anthropic&#8221;: {

      &#8220;options&#8221;: {

        &#8220;apiKey&#8221;: &#8220;{file:~/.secrets/anthropic-key.txt}&#8221;

      }

    }

  }

}</code></pre><p></p><h4>4. Team &amp; Collaboration Config (Enterprise-ready)</h4><h4>A. Sharing Configuration</h4><ul><li><p><strong>Manual sharing (recommended cho team):</strong></p></li></ul><pre><code>{

  &#8220;share&#8221;: &#8220;manual&#8221; // Default: ch&#7881; share khi d&#249;ng /share command

}</code></pre><p><strong>Options:</strong> <code>&#8221;manual&#8221;</code> | <code>&#8221;auto&#8221;</code> | <code>&#8221;disabled&#8221;</code></p><h4>B. Disabled Providers Management</h4><ul><li><p><strong>Ch&#7863;n providers kh&#244;ng c&#7847;n thi&#7871;t:</strong></p></li></ul><pre><code>{

  &#8220;disabled_providers&#8221;: [&#8221;openai&#8221;, &#8220;gemini&#8221;]

}</code></pre><blockquote><p><strong>L&#432;u &#253;:</strong> <code>disabled_providers</code> ch&#7863;n ho&#224;n to&#224;n, k&#7875; c&#7843; khi c&#243; credentials.</p></blockquote><p></p><h3>5. Hands-on Workshop: T&#7841;o config cho project c&#7911;a b&#7841;n</h3><h4>B&#432;&#7899;c 1: Global foundation config</h4><p>T&#7841;o file `~/.config/opencode/opencode.json`:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;theme&#8221;: &#8220;opencode&#8221;,

  &#8220;autoupdate&#8221;: true,

  &#8220;share&#8221;: &#8220;manual&#8221;,

  &#8220;permission&#8221;: {

    &#8220;write&#8221;: &#8220;ask&#8221;,

    &#8220;edit&#8221;: &#8220;ask&#8221;,

    &#8220;bash&#8221;: &#8220;ask&#8221;,

    &#8220;delete&#8221;: &#8220;ask&#8221;

  }

}</code></pre><p><strong>Test: </strong>Kh&#7903;i &#273;&#7897;ng OpenCode &#273;&#7875; xem c&#243; l&#7895;i kh&#244;ng:</p><pre><code>opencode --version  # Ki&#7875;m tra version
opencode            # M&#7903; TUI, n&#7871;u kh&#244;ng b&#225;o l&#7895;i config &#8594; OK</code></pre><h4>B&#432;&#7899;c 2: Project-specific config</h4><p>T&#7841;o file `./opencode.json` trong project:</p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

  &#8220;small_model&#8221;: &#8220;anthropic/claude-3-5-haiku-20241022&#8221;,

  &#8220;provider&#8221;: {

    &#8220;anthropic&#8221;: {

      &#8220;options&#8221;: {

        &#8220;apiKey&#8221;: &#8220;{env:ANTHROPIC_API_KEY}&#8221;

      }

    }

  }

}</code></pre><h4>B&#432;&#7899;c 3: Test config ho&#224;n ch&#7881;nh</h4><pre><code># 1. Test trong project

cd your-project

opencode

# 2. Trong OpenCode, test c&#225;c commands:

/models  # Xem danh s&#225;ch models

/init    # Initialize project

# 3. Test v&#7899;i message:

opencode run &#8220;What models are available?&#8221;

# 4. Test agents (n&#7871;u &#273;&#227; config):

opencode agent list  # Xem danh s&#225;ch agents</code></pre><blockquote><p><strong>Validation:</strong> N&#7871;u config c&#243; l&#7895;i, OpenCode s&#7869; b&#225;o l&#7895;i khi kh&#7903;i &#273;&#7897;ng. N&#7871;u kh&#244;ng th&#7845;y l&#7895;i &#8594; config OK! B&#7841;n c&#361;ng c&#243; th&#7875; ki&#7875;m tra b&#7857;ng c&#225;ch xem models c&#243; hi&#7875;n th&#7883; &#273;&#250;ng kh&#244;ng v&#7899;i l&#7879;nh <code>/models</code>.</p></blockquote><p></p><h3>6. Template Library (Copy-paste ngay)</h3><h4>A. Minimal Config Template</h4><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

  &#8220;provider&#8221;: {

    &#8220;anthropic&#8221;: {

      &#8220;options&#8221;: {

        &#8220;apiKey&#8221;: &#8220;{env:ANTHROPIC_API_KEY}&#8221;

      }

    }

  },

  &#8220;permission&#8221;: {

    &#8220;edit&#8221;: &#8220;ask&#8221;,

    &#8220;bash&#8221;: &#8220;ask&#8221;

  }

}</code></pre><h4>B. Team Config Template</h4><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

  &#8220;small_model&#8221;: &#8220;anthropic/claude-3-5-haiku-20241022&#8221;,

  &#8220;share&#8221;: &#8220;manual&#8221;,

  &#8220;permission&#8221;: {

    &#8220;write&#8221;: &#8220;ask&#8221;,

    &#8220;edit&#8221;: &#8220;ask&#8221;,

    &#8220;bash&#8221;: &#8220;ask&#8221;,

    &#8220;delete&#8221;: &#8220;ask&#8221;

  },

  &#8220;disabled_providers&#8221;: [&#8221;openai&#8221;],

  &#8220;instructions&#8221;: [&#8221;{file:./team-instructions.md}&#8221;]

}</code></pre><h4>C. Advanced Power User Config</h4><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

  &#8220;small_model&#8221;: &#8220;anthropic/claude-3-5-haiku-20241022&#8221;,

  &#8220;autoupdate&#8221;: true,

  &#8220;tui&#8221;: {

    &#8220;scroll_speed&#8221;: 2

  },

  &#8220;tools&#8221;: {

    &#8220;write&#8221;: true,

    &#8220;bash&#8221;: true,

    &#8220;edit&#8221;: true

  },

  &#8220;agent&#8221;: {

    &#8220;security_reviewer&#8221;: {

      &#8220;description&#8221;: &#8220;Security-focused code reviewer&#8221;,

      &#8220;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;,

      &#8220;prompt&#8221;: &#8220;Focus on security vulnerabilities and best practices&#8221;,

      &#8220;tools&#8221;: {

        &#8220;write&#8221;: false,

        &#8220;edit&#8221;: false

      }

    }

  },

  &#8220;command&#8221;: {

    &#8220;component&#8221;: {

      &#8220;template&#8221;: &#8220;Create React component with TypeScript and tests&#8221;,

      &#8220;description&#8221;: &#8220;Create component&#8221;

    }

  }

}</code></pre><p></p><h3>7. Common Config Mistakes (T&#244;i &#273;&#227; m&#7855;c h&#7871;t)</h3><h4>1. Syntax JSON sai</h4><blockquote><p><strong>Sai:</strong> Thi&#7871;u d&#7845;u ph&#7849;y, ngo&#7863;c</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> D&#249;ng JSON validator, copy t&#7915; template</p></div><h4>2. Model ID kh&#244;ng ch&#237;nh x&#225;c</h4><blockquote><p><strong>Sai:</strong> <code>&#8221;model&#8221;: &#8220;claude-3&#8221;</code> (ghi sai t&#234;n model ID)</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> <code>&#8221;model&#8221;: &#8220;anthropic/claude-3-5-sonnet-20241022&#8221;</code> (full ID)</p></div><p><strong>L&#432;u &#253;": </strong>B&#7841;n c&#243; th&#7875; t&#236;m ki&#7871;m <code>full ID</code> &#273;&#250;ng chu&#7849;n trong opencode system t&#7915; <a href="https://models.dev/">&#273;&#226;y</a>.</p><h4>3. Provider ch&#432;a authenticate</h4><blockquote><p><strong>Sai:</strong> Config xong kh&#244;ng ch&#7841;y <code>opencode auth login</code></p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> Login tr&#432;&#7899;c &#8594; config sau &#8594; test v&#7899;i <code>/models</code></p></div><h4>4. Permission qu&#225; strict</h4><blockquote><p><strong>Sai:</strong> Disable h&#7871;t m&#7885;i th&#7913; &#8594; AI kh&#244;ng l&#224;m &#273;&#432;&#7907;c g&#236;</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> Ch&#7881; ch&#7863;n nh&#7919;ng g&#236; th&#7921;c s&#7921; nguy hi&#7875;m</p></div><h4>5. Kh&#244;ng test config sau khi vi&#7871;t</h4><blockquote><p><strong>Sai:</strong> Vi&#7871;t xong kh&#244;ng test &#8594; l&#7895;i kh&#244;ng bi&#7871;t</p></blockquote><div class="pullquote"><p><strong>&#272;&#250;ng:</strong> Test v&#7899;i <code>opencode</code> v&#224; <code>/models</code> &#273;&#7875; verify</p></div><p></p><h3>8. Best Practices &amp; Performance Tips</h3><h4>A. Cost Optimization</h4><ul><li><p>D&#249;ng <code>small_model</code> cho tasks nh&#7865; (ti&#7871;t ki&#7879;m 70%)</p></li><li><p>Disable providers kh&#244;ng d&#249;ng</p></li><li><p>Test v&#7899;i model r&#7867; tr&#432;&#7899;c, sau &#273;&#243; scale up</p></li></ul><h4>B. Team Collaboration</h4><ul><li><p>Commit <code>opencode.json</code> v&#224;o Git</p></li><li><p>D&#249;ng environment variables cho secrets</p></li><li><p>T&#7841;o team guidelines trong instructions</p></li></ul><h4>C. Security First</h4><ul><li><p>Kh&#244;ng hardcode API keys</p></li><li><p>Review permissions cho team members</p></li><li><p>D&#249;ng <code>disabled_providers</code> thay v&#236; x&#243;a credentials</p></li></ul><p></p><h3>9. K&#7871;t lu&#7853;n: B&#7841;n &#273;&#227; c&#243; config v&#7919;ng ch&#7855;c</h3><p>Config &#273;&#250;ng gi&#250;p b&#7841;n:</p><ul><li><p><strong>Ti&#7871;t ki&#7879;m 30 ph&#250;t m&#7895;i ng&#224;y</strong> &#8594; 150 gi&#7901;/n&#259;m</p></li><li><p><strong>Team &#273;&#7891;ng b&#7897;</strong> &#8594; Kh&#244;ng c&#242;n &#8220;sao m&#225;y anh ch&#7841;y &#273;&#432;&#7907;c?&#8221;</p></li><li><p><strong>Security chu&#7849;n</strong> &#8594; Tr&#225;nh AI l&#224;m h&#7887;ng h&#7879; th&#7889;ng</p></li><li><p><strong>Cost optimization</strong> &#8594; Kh&#244;ng t&#7889;n ti&#7873;n v&#244; &#237;ch</p></li></ul><blockquote><p><strong>Challenge:</strong> H&#227;y setup config cho project c&#7911;a b&#7841;n. Sau &#273;&#243; share:</p></blockquote><ul><li><p>B&#7841;n d&#249;ng template n&#224;o?</p></li><li><p>C&#243; l&#7895;i g&#236; khi setup?</p></li><li><p>Config n&#224;o h&#7919;u &#237;ch nh&#7845;t?</p></li></ul><p><strong>Test k&#7871;t qu&#7843;:</strong></p><pre><code>cd your-project

opencode

# Trong OpenCode, g&#245;: /models &#273;&#7875; xem config c&#243; ho&#7841;t &#273;&#7897;ng kh&#244;ng</code></pre><p><strong>Next step:</strong> Trong b&#224;i 4, t&#244;i s&#7869; d&#7841;y b&#7841;n master TUI - giao di&#7879;n terminal ho&#224;n h&#7843;o &#273;&#7875; l&#224;m vi&#7879;c nh&#432; senior dev. B&#7841;n s&#7869; th&#7845;y c&#225;ch t&#7889;i &#432;u layout, themes, v&#224; keybinds cho productivity t&#7889;i &#273;a.</p><div><hr></div><p><strong>Homework:</strong> Sau khi c&#243; config chu&#7849;n, h&#227;y th&#7917; l&#224;m vi&#7879;c v&#7899;i TUI 1 tu&#7847;n. Note l&#7841;i nh&#7919;ng g&#236; b&#7841;n mu&#7889;n c&#7843;i thi&#7879;n v&#7873; layout, themes, ho&#7863;c keybinds. Trong b&#224;i 4, t&#244;i s&#7869; d&#7841;y b&#7841;n optimize t&#7845;t c&#7843;!</p>]]></content:encoded></item><item><title><![CDATA[Cài OpenCode trong 15 phút - Không cần làm Linux expert]]></title><description><![CDATA[H&#432;&#7899;ng d&#7851;n c&#224;i &#273;&#7863;t OpenCode chi ti&#7871;t cho ng&#432;&#7901;i m&#7899;i b&#7855;t &#273;&#7847;u]]></description><link>https://heyhuynhgiabuu.substack.com/p/cai-opencode-trong-15-phut-khong</link><guid isPermaLink="false">https://heyhuynhgiabuu.substack.com/p/cai-opencode-trong-15-phut-khong</guid><dc:creator><![CDATA[Huynh Gia Buu]]></dc:creator><pubDate>Tue, 28 Oct 2025 06:46:10 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/8029ff2b-4a27-4937-b097-a7f1dd1898c1_3456x2234.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>Khi t&#244;i ngh&#297; c&#224;i &#273;&#7863;t AI ph&#7843;i c&#243; b&#7857;ng ti&#7871;n s&#297;</h3><p>Th&#250; th&#7853;t, l&#7847;n &#273;&#7847;u nghe &#273;&#7871;n &#8220;AI coding agent&#8221;, t&#244;i t&#432;&#7903;ng ph&#7843;i c&#224;i &#273;&#7863;t g&#236; si&#234;u ph&#7913;c t&#7841;p. Lo&#7841;i tool n&#224;y ch&#7855;c c&#7847;n server ri&#234;ng, database, v&#224; c&#7843; &#273;&#7897;i ng&#361; DevOps &#273;&#7875; maintain ch&#7913; nh&#7881;?</p><p>Ho&#225; ra kh&#244;ng ph&#7843;i v&#7853;y.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>OpenCode c&#224;i &#273;&#417;n gi&#7843;n nh&#432; c&#224;i... Facebook v&#7853;y. Ch&#7881; c&#7847;n v&#224;i c&#226;u l&#7879;nh, v&#224;i c&#250; click, xong. Kh&#244;ng c&#7847;n b&#7841;n ph&#7843;i bi&#7871;t Linux, kh&#244;ng c&#7847;n setup server, kh&#244;ng c&#7847;n h&#7885;c 50 c&#226;u l&#7879;nh terminal.</p><p>H&#244;m nay t&#244;i s&#7869; ch&#7881; b&#7841;n c&#225;ch c&#224;i OpenCode trong 15 ph&#250;t th&#7921;c s&#7921;. Kh&#244;ng &#7843;o t&#432;&#7903;ng, kh&#244;ng qu&#7843;ng c&#225;o v&#7899; v&#7849;n.</p><p></p><h3>Chu&#7849;n b&#7883;: Ki&#7875;m tra &#8220;s&#7913;c kho&#7867;&#8221; m&#225;y t&#237;nh</h3><p>Tr&#432;&#7899;c khi c&#224;i, ki&#7875;m tra m&#225;y b&#7841;n c&#243; &#273;&#7911; &#8220;s&#7913;c&#8221; kh&#244;ng:</p><h4>1. Terminal emulator</h4><p>OpenCode ch&#7841;y trong terminal, nh&#432;ng kh&#244;ng ph&#7843;i terminal m&#7863;c &#273;&#7883;nh c&#7911;a Windows &#273;&#226;u. B&#7841;n c&#7847;n 1 trong nh&#7919;ng th&#7857;ng n&#224;y:</p><p><strong>Mac/Linux:</strong></p><ul><li><p>iTerm2 (Mac) - mi&#7877;n ph&#237;, &#273;&#7865;p</p></li><li><p>Terminal m&#7863;c &#273;&#7883;nh c&#361;ng &#273;&#432;&#7907;c</p></li><li><p>WezTerm n&#7871;u b&#7841;n th&#237;ch &#8220;h&#224;ng x&#7883;n&#8221;</p></li></ul><p><strong>Windows:</strong></p><ul><li><p>Windows Terminal (c&#224;i t&#7915; Microsoft Store)</p></li><li><p>WezTerm (cross-platform)</p></li><li><p>Ho&#7863;c d&#249;ng WSL2 n&#7871;u b&#7841;n th&#237;ch Linux</p></li></ul><p><strong>Ki&#7875;m tra:</strong> M&#7903; terminal l&#234;n, g&#245;:</p><pre><code><code>echo &#8220;T&#244;i &#273;ang d&#249;ng $(echo $SHELL)&#8221;</code></code></pre><p>N&#7871;u th&#7845;y hi&#7879;n ra d&#242;ng ch&#7919;, t&#7913;c l&#224; terminal b&#7841;n OK r&#7891;i &#273;&#243;.</p><h4>2. Node.js version</h4><p>OpenCode c&#7847;n Node.js t&#7915; version 18 tr&#7903; l&#234;n. Ki&#7875;m tra nhanh:</p><pre><code>node --version</code></pre><p><strong>N&#7871;u c&#243; l&#7895;i &#8220;command not found&#8221;:</strong> Ch&#432;a c&#224;i Node.js, nh&#7843;y xu&#7889;ng ph&#7847;n &#8220;C&#224;i &#273;&#7863;t thi&#7871;u s&#243;t&#8221;.</p><p><strong>N&#7871;u version &lt; 18:</strong> C&#7847;n upgrade. V&#237; d&#7909; b&#7841;n th&#7845;y `v16.15.0`, th&#236; ph&#7843;i l&#234;n 18+.</p><p><strong>N&#7871;u version &gt;= 18:</strong> Perfect! B&#7887; qua ph&#7847;n c&#224;i Node.js.</p><h4>3. Git</h4><pre><code>git --version</code></pre><p>Kh&#244;ng c&#243; Git th&#236; c&#224;i th&#244;i. C&#243; r&#7891;i th&#236; th&#244;i.</p><p></p><h3>C&#224;i &#273;&#7863;t thi&#7871;u s&#243;t (n&#7871;u c&#7847;n)</h3><h4>C&#224;i Node.js &#273;&#250;ng c&#225;ch</h4><ul><li><p><strong>Mac (d&#249;ng Homebrew):</strong></p></li></ul><pre><code>brew install node</code></pre><ul><li><p><strong>Ubuntu/Debian</strong></p></li></ul><pre><code>curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs</code></pre><ul><li><p><strong>Window</strong></p></li></ul><ol><li><p>V&#224;o nodejs.org</p></li><li><p>T&#7843;i b&#7843;n LTS (m&#224;u xanh)</p></li><li><p>Next &#8594; Next &#8594; Install</p></li><li><p>Kh&#7903;i &#273;&#7897;ng l&#7841;i terminal</p></li></ol><h4>C&#224;i Git</h4><ul><li><p><strong>Mac</strong></p></li></ul><pre><code>brew install git</code></pre><ul><li><p><strong>Ubuntu</strong></p></li></ul><pre><code><code>sudo apt update &amp;&amp; sudo apt install git</code></code></pre><ul><li><p><strong>Window</strong></p></li></ul><p>T&#7843;i t&#7915; git-scm.com, c&#224;i nh&#432; b&#236;nh th&#432;&#7901;ng.</p><p></p><h3>C&#224;i OpenCode (5 ph&#250;t th&#7921;c s&#7921;)</h3><p>C&#243; 3 c&#225;ch c&#224;i. T&#244;i recommend c&#225;ch 1, &#273;&#417;n gi&#7843;n nh&#7845;t:</p><h4>C&#225;ch 1: Script t&#7921; &#273;&#7897;ng (Recommended)</h4><pre><code>curl -fsSL https://opencode.ai/install | bash</code></pre><p>Ch&#7901; 30 gi&#226;y, xong. Script s&#7869;:</p><ul><li><p>T&#7921; detect OS c&#7911;a b&#7841;n</p></li><li><p>C&#224;i &#273;&#250;ng version</p></li><li><p>Setup PATH</p></li><li><p>Verify installation</p></li></ul><p><strong>N&#7871;u g&#7863;p l&#7895;i:</strong> Th&#7917; c&#225;ch 2.</p><h4>C&#225;ch 2: NPM (lu&#244;n &#273;&#250;ng)</h4><pre><code>npm install -g opencode-ai</code></pre><p>Ch&#7901; 1-2 ph&#250;t t&#249;y m&#7841;ng. NPM s&#7869; t&#7843;i v&#7873; v&#224; c&#224;i global.</p><p><strong>Verify:</strong></p><pre><code>opencode --version</code></pre><p>Th&#7845;y hi&#7879;n version (v&#237; d&#7909;: `v2.1.0`) = th&#224;nh c&#244;ng!</p><h4>C&#225;ch 3: Homebrew (Mac/Linux)</h4><pre><code>brew install sst/tap/opencode</code></pre><p>C&#225;ch n&#224;y c&#361;ng OK, nh&#432;ng &#273;&#244;i khi version ch&#7853;m h&#417;n 1-2 b&#7843;n.</p><p></p><h3>K&#7871;t n&#7889;i v&#7899;i AI: L&#7845;y API key</h3><p>OpenCode c&#7847;n AI &#273;&#7875; ho&#7841;t &#273;&#7897;ng. C&#243; 2 c&#225;ch:</p><h4>C&#225;ch d&#7877; nh&#7845;t: OpenCode Zen (Recommend cho ng&#432;&#7901;i m&#7899;i)</h4><p>1. Ch&#7841;y:</p><pre><code>opencode auth login</code></pre><p>2. Ch&#7885;n &#8220;opencode&#8221; t&#7915; menu</p><p>3. N&#243; s&#7869; hi&#7879;n link: https://opencode.ai/auth</p><p>4. Click v&#224;o link, &#273;&#259;ng k&#253;, l&#7845;y API key</p><p>5. Paste v&#224;o terminal</p><p><strong>&#431;u &#273;i&#7875;m:</strong> Kh&#244;ng c&#7847;n setup g&#236; th&#234;m, d&#249;ng model &#273;&#227; test s&#7861;n.</p><h4>C&#225;ch pro: D&#249;ng provider t&#249;y ch&#7881;nh (OpenAI-compatible)</h4><p>N&#7871;u b&#7841;n c&#243; API key c&#7911;a Claude, OpenAI, ho&#7863;c b&#7845;t k&#7923; provider n&#224;o kh&#225;c, th&#234;m qua `opencode auth login`:</p><p>1. <strong>Ch&#7841;y l&#7879;nh:</strong></p><pre><code>opencode auth login</code></pre><p>2.<strong>Ch&#7885;n &#8220;Other</strong>&#8221; t&#7915; danh s&#225;ch providers</p><p>3. <strong>Nh&#7853;p provider ID</strong> (v&#237; d&#7909;: &#8220;anthropic&#8221;, &#8220;openai&#8221;, &#8220;custom-ai&#8221;)</p><p>4. <strong>Nh&#7853;p API key</strong> c&#7911;a b&#7841;n</p><p>5. <strong>T&#7841;o config trong opencode.json:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;provider&#8221;: {

    &#8220;anthropic&#8221;: {

      &#8220;npm&#8221;: &#8220;@ai-sdk/anthropic&#8221;,

      &#8220;name&#8221;: &#8220;Anthropic Claude&#8221;,

      &#8220;models&#8221;: {

        &#8220;claude-3-5-sonnet-20241022&#8221;: {

          &#8220;name&#8221;: &#8220;Claude 3.5 Sonnet&#8221;

        }

      }

    }

  }

}</code></pre><p><strong>Ho&#7863;c cho OpenAI-compatible providers:</strong></p><pre><code>{

  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,

  &#8220;provider&#8221;: {

    &#8220;myprovider&#8221;: {

      &#8220;npm&#8221;: &#8220;@ai-sdk/openai-compatible&#8221;,

      &#8220;name&#8221;: &#8220;My AI Provider&#8221;,

      &#8220;options&#8221;: {

        &#8220;baseURL&#8221;: &#8220;https://api.myprovider.com/v1&#8221;

      },

      &#8220;models&#8221;: {

        &#8220;my-model&#8221;: {

          &#8220;name&#8221;: &#8220;My Model&#8221;

        }

      }

    }

  }

}</code></pre><div class="pullquote"><p><strong>Xem t&#7845;t c&#7843; providers h&#7895; tr&#7907;:</strong> Ch&#7841;y `/models` trong OpenCode &#273;&#7875; th&#7845;y danh s&#225;ch complete.</p></div><p></p><h3>Test th&#7917;: M&#7903; OpenCode l&#7847;n &#273;&#7847;u</h3><p>1. V&#224;o 1 project b&#7845;t k&#7923; (ho&#7863;c t&#7841;o m&#7899;i):</p><pre><code>mkdir test-project &amp;&amp; cd test-project
git init  # OpenCode c&#7847;n git repo</code></pre><p>2. Ch&#7841;y:</p><pre><code>opencode</code></pre><p>3. Trong OpenCode, g&#245;:</p><pre><code>/init</code></pre><ul><li><p><strong>K&#7871;t qu&#7843; &#273;&#250;ng:</strong> Th&#7845;y OpenCode analyze project, t&#7841;o file `AGENTS.md`.</p></li><li><p><strong>K&#7871;t qu&#7843; sai:</strong> Hi&#7879;n l&#7895;i &#273;&#7887;. &#272;&#7885;c ti&#7871;p ph&#7847;n &#8220;Fix l&#7895;i th&#432;&#7901;ng g&#7863;p&#8221;.</p></li></ul><p></p><h3>Fix l&#7895;i th&#432;&#7901;ng g&#7863;p (kh&#244;ng ai tr&#225;nh &#273;&#432;&#7907;c)</h3><h4>L&#7895;i 1: &#8220;opencode: command not found&#8221;</h4><blockquote><p><strong>Nguy&#234;n nh&#226;n:</strong> PATH ch&#432;a update.</p></blockquote><p><strong>Fix:</strong></p><ul><li><p>Mac/Linux</p></li></ul><pre><code>export PATH=&#8221;$PATH:/usr/local/bin&#8221;</code></pre><ul><li><p>Windows (trong Git Bash)</p></li></ul><pre><code>export PATH=&#8221;$PATH:/c/Users/$(whoami)/AppData/Roaming/npm&#8221;</code></pre><p><strong>Permanent fix:</strong> Kh&#7903;i &#273;&#7897;ng l&#7841;i terminal, ho&#7863;c reboot m&#225;y.</p><h4>L&#7895;i 2: &#8220;Permission denied&#8221;</h4><blockquote><p><strong>Nguy&#234;n nh&#226;n:</strong> NPM permissions l&#7895;i.</p></blockquote><p><strong>Fix nhanh:</strong></p><pre><code>sudo npm install -g opencode-ai</code></pre><p><strong>Fix &#273;&#250;ng:</strong> Fix NPM permissions (xem npmjs.com)</p><h4>L&#7895;i 3: &#8220;Model not available&#8221;</h4><blockquote><p><strong>Nguy&#234;n nh&#226;n:</strong> API key sai ho&#7863;c h&#7871;t ti&#7873;n.</p></blockquote><p><strong>Fix:</strong></p><ul><li><p>Ki&#7875;m tra key c&#243; &#273;&#250;ng kh&#244;ng</p></li><li><p>V&#224;o dashboard provider xem c&#242;n credits kh&#244;ng</p></li><li><p>Th&#7917; model kh&#225;c: `opencode config set model gpt-4`</p></li></ul><h4>L&#7895;i 4: &#8220;Not a git repository&#8221;</h4><blockquote><p><strong>Nguy&#234;n nh&#226;n:</strong> Ch&#7841;y OpenCode ngo&#224;i git repo.</p></blockquote><p><strong>Fix:</strong></p><pre><code>git init  # trong th&#432; m&#7909;c project</code></pre><p></p><h3>Script t&#7921; &#273;&#7897;ng ki&#7875;m tra (bonus)</h3><p>T&#244;i vi&#7871;t script gi&#250;p b&#7841;n check m&#7885;i th&#7913; t&#7921; &#273;&#7897;ng:</p><pre><code>#!/bin/bash

echo &#8220;&#128269; Ki&#7875;m tra OpenCode installation...&#8221;

# Check Node.js

if command -v node &amp;&gt; /dev/null; then

    NODE_VERSION=$(node --version)

    echo &#8220;&#9989; Node.js: $NODE_VERSION&#8221;

else

    echo &#8220;&#10060; Node.js ch&#432;a c&#224;i&#8221;

    exit 1

fi

# Check OpenCode

if command -v opencode &amp;&gt; /dev/null; then

    echo &#8220;&#9989; OpenCode: $(opencode --version)&#8221;

else

    echo &#8220;&#10060; OpenCode ch&#432;a c&#224;i&#8221;

    exit 1

fi

# Test functionality

echo &#8220;&#129514; Testing basic functionality...&#8221;

cd /tmp

mkdir opencode-test-$$ &amp;&amp; cd opencode-test-$$

git init --quiet

if opencode status &amp;&gt; /dev/null; then

    echo &#8220;&#9989; OpenCode ho&#7841;t &#273;&#7897;ng b&#236;nh th&#432;&#7901;ng&#8221;

else

    echo &#8220;&#10060; OpenCode g&#7863;p l&#7895;i&#8221;

fi

# Cleanup

cd ..

rm -rf opencode-test-$$

echo &#8220;&#127881; Installation ho&#224;n t&#7845;t!&#8221;</code></pre><p>Save file l&#224; `check-opencode.sh`, ch&#7841;y:</p><pre><code>chmod +x check-opencode.sh

./check-opencode.sh</code></pre><p></p><h3>K&#7871;t lu&#7853;n: B&#7841;n &#273;&#227; c&#243; xe, nh&#432;ng ch&#432;a bi&#7871;t l&#225;i</h3><p>C&#224;i OpenCode xong, t&#244;i ngh&#297;: &#8220;Xong! Gi&#7901; th&#236; d&#249;ng th&#244;i.&#8221;</p><p>Sai b&#233;t.</p><p>Gi&#7889;ng nh&#432; m&#7899;i mua xe m&#225;y v&#7853;y - b&#7841;n c&#243; xe r&#7891;i, nh&#432;ng n&#7871;u kh&#244;ng bi&#7871;t l&#225;i th&#236; ch&#7881; &#273;&#7875; ng&#7855;m th&#244;i.</p><p>T&#244;i &#273;&#227; m&#7845;t 3 th&#225;ng &#273;&#7875; hi&#7875;u &#273;i&#7873;u n&#224;y. 3 th&#225;ng &#273;&#7847;u v&#7899;i OpenCode c&#7911;a t&#244;i nh&#432; th&#7871; n&#224;y:</p><ul><li><p>M&#7895;i l&#7847;n &#273;&#7893;i project: m&#7845;t 30 ph&#250;t setup l&#7841;i</p></li><li><p>Team member h&#7887;i: &#8220;Sao m&#225;y anh ch&#7841;y &#273;&#432;&#7907;c, m&#225;y em kh&#244;ng &#273;&#432;&#7907;c?&#8221;</p></li><li><p>L&#7895;i &#8220;Model not available&#8221; ho&#224;i, kh&#244;ng hi&#7875;u t&#7841;i sao</p></li><li><p>C&#7913; ph&#7843;i g&#245; l&#7841;i c&#249;ng c&#226;u l&#7879;nh, c&#249;ng c&#7845;u h&#236;nh</p></li></ul><p>Nguy&#234;n nh&#226;n: T&#244;i kh&#244;ng bi&#7871;t <strong>config &#273;&#250;ng c&#225;ch</strong>.</p><h3>&#272;i&#7873;u g&#236; s&#7869; x&#7843;y ra n&#7871;u b&#7841;n config sai?</h3><ul><li><p>D&#249;ng model sai &#8594; T&#7889;n ti&#7873;n v&#244; &#237;ch</p></li><li><p>Permission kh&#244;ng &#273;&#250;ng &#8594; AI xo&#225; nh&#7847;m file quan tr&#7885;ng</p></li><li><p>Kh&#244;ng c&#243; custom commands &#8594; M&#7845;t 10 ph&#250;t cho vi&#7879;c ch&#7881; c&#7847;n 30 gi&#226;y</p></li><li><p>Team kh&#244;ng chung config &#8594; H&#7895;n lo&#7841;n, m&#7895;i ng&#432;&#7901;i m&#7897;t ki&#7875;u</p></li></ul><p></p><h3>Tin vui: B&#7841;n kh&#244;ng c&#7847;n m&#7845;t 3 th&#225;ng nh&#432; t&#244;i</h3><p>Trong b&#224;i ti&#7871;p theo, t&#244;i s&#7869; d&#7841;y b&#7841;n config OpenCode <strong>&#273;&#250;ng chu&#7849;n senior dev</strong>:</p><p>&#9989; <strong>15 ph&#250;t setup</strong> - d&#249;ng c&#7843; n&#259;m kh&#244;ng ph&#7843;i s&#7917;a</p><p>&#9989; <strong>Config chu&#7849;n</strong> - validated v&#7899;i official schema  </p><p>&#9989; <strong>T&#249;y ch&#7881;nh th&#244;ng minh</strong> - theme, keybinds, permissions</p><p>&#9989; <strong>Custom commands</strong> - t&#7921; &#273;&#7897;ng ho&#225; tasks l&#7863;p &#273;i l&#7863;p l&#7841;i</p><p>&#9989; <strong>Team-friendly</strong> - share config, &#273;&#7891;ng b&#7897; workflow</p><p><strong>&#272;&#7863;c bi&#7879;t:</strong> T&#244;i s&#7869; cho b&#7841;n 3 templates config cho 3 lo&#7841;i project ph&#7893; bi&#7871;n:</p><ul><li><p>Web App (React/Next.js)</p></li><li><p>Mobile (React Native)</p></li><li><p>Backend (Node.js/Express)</p></li></ul><p>Copy-paste &#8594; d&#249;ng ngay &#8594; kh&#244;ng c&#7847;n ngh&#297;.</p><p></p><h3>Challenge: Test config hi&#7879;n t&#7841;i c&#7911;a b&#7841;n</h3><p>Tr&#432;&#7899;c khi h&#7885;c config m&#7899;i, ki&#7875;m tra c&#224;i &#273;&#7863;t c&#7911;a b&#7841;n:</p><pre><code># 1. Ki&#7875;m tra c&#224;i &#273;&#7863;t

opencode --version

# 2. Test v&#7899;i project th&#7853;t

cd your-project

git status  # &#273;&#7843;m b&#7843;o l&#224; git repo

opencode    # m&#7903; OpenCode l&#234;n</code></pre><p>Trong OpenCode, th&#7917; g&#245;:</p><pre><code>/init</code></pre><p><strong>N&#7871;u th&#7845;y OpenCode analyze project v&#224; t&#7841;o file `</strong><code>AGENTS.md</code><strong>`</strong> &#8594; C&#224;i &#273;&#7863;t OK, ch&#7881; thi&#7871;u config</p><p><strong>N&#7871;u g&#7863;p l&#7895;i</strong> &#8594; Comment l&#7895;i, t&#244;i s&#7869; gi&#250;p fix</p><blockquote><p><strong>Homework nh&#7865;:</strong> Ch&#7909;p screenshot k&#7871;t qu&#7843; `<code>/init</code>` v&#224; share trong comments. T&#244;i s&#7869; check xem b&#7841;n &#273;ang d&#249;ng model n&#224;o, c&#243; c&#7847;n optimize kh&#244;ng.</p></blockquote><div><hr></div><p><strong>Next stop:</strong> B&#224;i 3 - &#8220;Config OpenCode nh&#432; senior: 15 ph&#250;t setup &#273;&#7875; d&#249;ng 1 n&#259;m kh&#244;ng ph&#7843;i s&#7917;a&#8221;</p><div class="pullquote"><p>_P/S: N&#7871;u b&#7841;n th&#7845;y config n&#224;o kh&#243; hi&#7875;u trong b&#224;i 3, comment ngay. T&#244;i s&#7869; gi&#7843;i th&#237;ch th&#234;m._</p></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://heyhuynhgiabuu.substack.com/subscribe?"><span>Subscribe now</span></a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Tôi bỏ việc kỹ sư để học code: 2 năm thất bại trước khi tìm ra OpenCode]]></title><description><![CDATA[Th&#225;ng 3/2022 t&#244;i ngh&#7881; vi&#7879;c k&#7929; s&#432; m&#244;i tr&#432;&#7901;ng. Th&#225;ng 11/2025 t&#244;i &#273;&#7841;t productivity t&#259;ng 3x nh&#7901; OpenCode. &#272;&#226;y l&#224; chu&#7895;i sai l&#7847;m &#273;&#7855;t gi&#225; v&#224; b&#224;i h&#7885;c th&#7921;c t&#7871; v&#7873; t&#7853;n d&#7909;ng AI &#273;&#250;ng c&#225;ch.]]></description><link>https://heyhuynhgiabuu.substack.com/p/toi-bo-viec-ky-su-e-hoc-code-2-nam</link><guid isPermaLink="false">https://heyhuynhgiabuu.substack.com/p/toi-bo-viec-ky-su-e-hoc-code-2-nam</guid><dc:creator><![CDATA[Huynh Gia Buu]]></dc:creator><pubDate>Sat, 25 Oct 2025 14:25:09 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/c7d7a980-5e58-4a11-80ec-0403e7ebff4e_5120x2880.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>C&#226;u chuy&#7879;n th&#7921;c t&#7871;: T&#7915; k&#7929; s&#432; m&#244;i tr&#432;&#7901;ng &#273;&#7871;n dev remote cho c&#244;ng ty Anh</h3><p>Th&#225;ng 3/2022, t&#244;i n&#7897;p &#273;&#417;n xin ngh&#7881; vi&#7879;c. Kh&#244;ng c&#243; job m&#7899;i. Kh&#244;ng c&#243; k&#7871; ho&#7841;ch. Ch&#7881; c&#243; quy&#7871;t t&#226;m: &#8220;Ph&#7843;i tho&#225;t kh&#7887;i ng&#224;nh n&#224;y.&#8221;</p><p>3 th&#225;ng &#273;&#7847;u ti&#234;n: H&#7885;c Google UX Design tr&#234;n Coursera + Figma. T&#244;i ngh&#297;: </p><div class="pullquote"><p>&#8220;Thi&#7871;t k&#7871; c&#361;ng g&#7847;n l&#7853;p tr&#236;nh m&#224;.&#8221;</p></div><p>Th&#225;ng 6/2022: B&#7855;t &#273;&#7847;u h&#7885;c code th&#7921;c s&#7921;. HTML/CSS/JavaScript/SQL. R&#7891;i React. R&#7891;i sao ch&#233;p tutorial tr&#234;n YouTube. R&#417;i v&#224;o tutorial hell &#273;&#250;ng ngh&#297;a.</p><p><strong>M&#7895;i ng&#224;y 6-8 ti&#7871;ng:</strong></p><ul><li><p>S&#225;ng: 8h-11h h&#7885;c JavaScript/SQL</p></li><li><p>Chi&#7873;u: 14h-17h l&#224;m project nh&#7887;</p></li><li><p>T&#7889;i: 20h-22h xem tutorial</p></li><li><p>Cu&#7889;i tu&#7847;n: 4 ti&#7871;ng h&#7885;c React</p></li></ul><blockquote><p><strong>K&#7871;t qu&#7843;:</strong> Code ho&#7841;t &#273;&#7897;ng nh&#432;ng kh&#244;ng hi&#7875;u t&#7841;i sao. Copy-paste 70%, hi&#7875;u 30%.</p></blockquote><h4>Th&#225;ng 3/2023: C&#250; s&#7889;c &#273;&#7847;u ti&#234;n</h4><p>T&#244;i n&#7897;p &#273;&#417;n xin vi&#7879;c. H&#417;n 50 c&#244;ng ty, kho&#7843;ng 1/2 &#273;a s&#7889; c&#225;c c&#244;ng ty t&#7915; ch&#7889;i &#273;&#7873;u l&#253; do: </p><div class="pullquote"><p>&#8220;Kh&#244;ng c&#243; kinh nghi&#7879;m th&#7921;c t&#7871;. (Th&#7921;c t&#7871; t&#244;i hi&#7875;u code c&#7911;a m&#236;nh copy t&#7915; tutorial qu&#225; nhi&#7873;u)&#8221;</p></div><p><strong>Ki&#7875;m tra th&#7921;c t&#7871;:</strong> Tutorial hell 9 th&#225;ng &#8800; l&#224;m vi&#7879;c th&#7921;c t&#7871; 9 th&#225;ng.</p><p></p><h3>Th&#225;ng 6/2023: Breakthrough - Job remote &#273;&#7847;u ti&#234;n</h3><h4>C&#244;ng ty agency gi&#225;o d&#7909;c &#7903; London</h4><p>H&#7885; c&#7847;n ng&#432;&#7901;i v&#7915;a l&#224;m dev v&#7915;a l&#224;m design cho website gi&#225;o d&#7909;c. T&#244;i n&#243;i: </p><div class="pullquote"><p>&#8220;T&#244;i h&#7885;c nhanh. Cho t&#244;i 2 tu&#7847;n th&#7917; vi&#7879;c.&#8221;</p></div><ul><li><p><strong>L&#432;&#417;ng:</strong> $600/th&#225;ng. </p></li><li><p><strong>C&#244;ng vi&#7879;c:</strong> Fix bug, th&#234;m feature, design giao di&#7879;n. </p></li><li><p><strong>Tech stack:</strong> WordPress, Java, Figma.</p></li></ul><p><strong>C&#244;ng vi&#7879;c th&#7921;c t&#7871;</strong>:</p><p>- S&#225;ng: Code Java backend cho h&#7879; th&#7889;ng CMS n&#7897;i b&#7897;</p><p>- Chi&#7873;u: Design giao di&#7879;n cho landing page</p><p>- T&#7889;i: Fix bug WordPress c&#7911;a kh&#225;ch</p><h4>1 n&#259;m &#273;&#7847;u: V&#7851;n kh&#244;ng d&#249;ng AI</h4><p>T&#244;i ti&#7871;p t&#7909;c l&#224;m th&#7911; c&#244;ng:</p><ul><li><p>&#272;&#7885;c documentation Java t&#7915;ng d&#242;ng</p></li><li><p>Debug WordPress b&#7857;ng var_dump</p></li><li><p>Google m&#7895;i l&#7895;i Java nh&#7887;</p></li><li><p>Stack Overflow v&#7851;n l&#224; ng&#432;&#7901;i b&#7841;n th&#226;n nh&#7845;t</p></li></ul><blockquote><p><strong>K&#7871;t qu&#7843;:</strong> Hi&#7875;u r&#245; t&#7915;ng d&#242;ng code. Bug &#237;t. Nh&#432;ng... ch&#7853;m nh&#432; r&#249;a.</p></blockquote><p></p><h3>Th&#225;ng 7/2025: C&#250; hit th&#7921;c t&#7871; - T&#244;i &#273;ang t&#7909;t l&#7841;i ph&#237;a sau</h3><h4>Video c&#7911;a &#8220;ng&#432;&#7901;i anh&#8221; tr&#234;n YouTube</h4><p>Anh &#7845;y show workflow v&#7899;i AI. Code 1 feature trong 30 ph&#250;t. T&#244;i m&#7845;t 3 ti&#7871;ng.</p><p><strong>T&#244;i nh&#7853;n ra:</strong> M&#236;nh &#273;ang l&#224;m vi&#7879;c nh&#432; 2022 trong n&#259;m 2025.</p><h4>FOMO b&#7855;t &#273;&#7847;u</h4><p>T&#244;i lao v&#224;o h&#7885;c:</p><ul><li><p>GitHub Copilot</p></li><li><p>ChatGPT</p></li><li><p>Cursor</p></li><li><p>V&#224;i tool kh&#225;c</p></li></ul><blockquote><p><strong>K&#7871;t qu&#7843;:</strong> R&#7889;i lo&#7841;n. Kh&#244;ng bi&#7871;t d&#249;ng c&#225;i n&#224;o. Code r&#7889;i h&#417;n. Deadline v&#7851;n &#273;&#7871;n.</p></blockquote><p></p><h3>Th&#225;ng 8/2025: Kh&#225;m ph&#225; - OpenCode</h3><h4>T&#7841;i sao OpenCode kh&#225;c bi&#7879;t?</h4><p>Kh&#244;ng ph&#7843;i AI vi&#7871;t code thay t&#244;i. AI gi&#250;p t&#244;i:</p><ul><li><p>Hi&#7875;u codebase c&#361; nhanh h&#417;n</p></li><li><p>T&#236;m bug ch&#237;nh x&#225;c h&#417;n</p></li><li><p>Vi&#7871;t spec r&#245; r&#224;ng h&#417;n</p></li><li><p>T&#7921; tin refactor h&#417;n</p></li></ul><h4>3 th&#225;ng th&#7921;c chi&#7871;n: Ch&#7881; s&#7889; th&#7921;c t&#7871;</h4><p><strong>Tr&#432;&#7899;c OpenCode:</strong></p><ul><li><p>Hi&#7875;u feature m&#7899;i: 2-3 ng&#224;y</p></li><li><p>Fix bug ph&#7913;c t&#7841;p: 4-6 ti&#7871;ng</p></li><li><p>Vi&#7871;t t&#224;i li&#7879;u: 1-2 ng&#224;y</p></li><li><p>V&#242;ng code review: M&#7845;t t&#7921; tin</p></li></ul><p><strong>Sau OpenCode:</strong></p><ul><li><p>Hi&#7875;u feature m&#7899;i: 1/2 ng&#224;y</p></li><li><p>Fix bug ph&#7913;c t&#7841;p: 1-2 ti&#7871;ng</p></li><li><p>Vi&#7871;t t&#224;i li&#7879;u: 2-3 ti&#7871;ng</p></li><li><p> V&#242;ng code review: Confident h&#417;n 80%</p></li></ul><h3></h3><div class="pullquote"><h3>S&#7921; th&#7853;t ph&#361; ph&#224;ng: </h3><p>T&#244;i &#273;&#227; sai &#7903; &#273;&#226;u?</p></div><h4>Sai l&#7847;m #1: T&#7921; h&#7885;c kh&#244;ng c&#243; &#273;&#7883;nh h&#432;&#7899;ng</h4><p>9 th&#225;ng h&#7885;c JavaScript nh&#432;ng kh&#244;ng bi&#7871;t n&#234;n h&#7885;c g&#236; ti&#7871;p theo. M&#7845;t 3 th&#225;ng h&#7885;c nh&#7919;ng th&#7913; kh&#244;ng d&#249;ng &#273;&#7871;n.</p><blockquote><p><strong>&#272;&#250;ng:</strong> C&#7847;n roadmap. C&#7847;n mentor. C&#7847;n feedback loop</p></blockquote><p></p><h4>Sai l&#7847;m #2: Kh&#244;ng t&#7853;n d&#7909;ng AI l&#224;m &#273;&#242;n b&#7849;y khi c&#243; c&#417; h&#7897;i</h4><p>1 n&#259;m &#273;&#7847;u l&#224;m remote, t&#244;i v&#7851;n l&#224;m m&#7885;i th&#7913; th&#7911; c&#244;ng. S&#7907; &#8220;d&#249;ng AI s&#7869; kh&#244;ng h&#7885;c &#273;&#432;&#7907;c g&#236;&#8221;.</p><blockquote><p><strong>&#272;&#250;ng:</strong> AI gi&#250;p h&#7885;c nhanh h&#417;n, kh&#244;ng ph&#7843;i h&#7885;c thay b&#7841;n.</p></blockquote><p></p><h4>Sai l&#7847;m #3: Kh&#244;ng theo d&#245;i ti&#7871;n &#273;&#7897;</h4><p>T&#244;i kh&#244;ng bi&#7871;t m&#236;nh ti&#7871;n b&#7897; bao nhi&#234;u. Kh&#244;ng c&#243; nh&#7919;ng ch&#7881; s&#7889;. Kh&#244;ng c&#243; &#273;i&#7875;m chu&#7849;n.</p><blockquote><p><strong>&#272;&#250;ng:</strong> Ph&#7843;i &#273;o l&#432;&#7901;ng &#273;&#7875; c&#7843;i thi&#7879;n.</p></blockquote><p></p><h3>C&#225;ch s&#7917; d&#7909;ng OpenCode th&#7921;c t&#7871; - Nh&#7919;ng g&#236; b&#7841;n th&#7921;c s&#7921; c&#7847;n</h3><blockquote><p><strong>Ki&#7875;m tra th&#7921;c t&#7871;:</strong> OpenCode m&#7863;c &#273;&#7883;nh cho ph&#233;p AI t&#7921; &#273;&#7897;ng edit file v&#224; ch&#7841;y bash commands. B&#7841;n ph&#7843;i config &#273;&#7875; an to&#224;n.</p></blockquote><h4>Setup b&#7855;t bu&#7897;c tr&#432;&#7899;c khi d&#249;ng</h4><p>T&#7841;o file `opencode.json` t&#7841;i root project:</p><pre><code>{
  &#8220;$schema&#8221;: &#8220;https://opencode.ai/config.json&#8221;,
  &#8220;permission&#8221;: {
    &#8220;edit&#8221;: &#8220;ask&#8221;,
    &#8220;bash&#8221;: &#8220;ask&#8221;
  },
  &#8220;model&#8221;: &#8220;anthropic/claude-sonnet-4-20250514&#8221;,
  &#8220;small_model&#8221;: &#8220;anthropic/claude-3-5-haiku-20241022&#8221;
}</code></pre><p><strong>T&#7841;i sao:</strong></p><ul><li><p><code>permission.ask</code> = b&#7841;n ph&#7843;i duy&#7879;t m&#7885;i thay &#273;&#7893;i file/l&#7879;nh shell tr&#432;&#7899;c khi ch&#7841;y</p></li><li><p><code>small_model</code> = ti&#7871;t ki&#7879;m ti&#7873;n cho tasks nh&#7865; (title, summaries)</p></li><li><p>File n&#224;y n&#234;n commit v&#224;o Git &#273;&#7875; c&#7843; team d&#249;ng chung config</p></li></ul><h4>Khi c&#7847;n hi&#7875;u codebase</h4><p>M&#7903; TUI, h&#7887;i tr&#7921;c ti&#7871;p v&#7899;i tham chi&#7871;u file (<code>@path</code>):</p><div class="pullquote"><p>Explain authentication flow in @src/main/java/.../SecurityConfig.java </p><p>List all REST endpoints in @src/main/java/.../controller/</p></div><p><strong>Kh&#244;ng c&#7847;n custom commands (</strong>ph&#7847;n n&#224;y n&#226;ng cao, m&#236;nh s&#7869; chia s&#7867; qua b&#224;i vi&#7871;t sau)<strong>.</strong> H&#7887;i th&#7859;ng l&#224; &#273;&#7911;.</p><h4>Khi c&#7847;n refactor ho&#7863;c l&#224;m feature l&#7899;n</h4><ul><li><p><strong>B&#432;&#7899;c 1:</strong> B&#7853;t ch&#7871; &#273;&#7897; Plan-only b&#7857;ng Tab key trong TUI (indicator g&#243;c d&#432;&#7899;i ph&#7843;i)</p></li><li><p><strong>B&#432;&#7899;c 2:</strong> H&#7887;i plan tr&#432;&#7899;c:</p></li></ul><div class="pullquote"><p>&#8220;Plan migration session-based auth &#8594; JWT</p><p>- List files c&#7847;n s&#7917;a</p><p>- Breaking changes l&#224; g&#236;</p><p>- Rollback strategy&#8221;</p></div><ul><li><p><strong>B&#432;&#7899;c 3:</strong> Review plan &#8594; Tab l&#7841;i &#273;&#7875; Build mode &#8594; cho AI code</p></li></ul><p><strong>Thay th&#7871;:</strong> N&#7871;u mu&#7889;n b&#7855;t bu&#7897;c plan-only b&#7857;ng config (&#237;t d&#249;ng):</p><pre><code>{

  &#8220;tools&#8221;: {

    &#8220;write&#8221;: false,

    &#8220;edit&#8221;: false

  }

}</code></pre><h4>Khi c&#7847;n AI tu&#226;n theo c&#225;c ti&#234;u coding</h4><p>Th&#234;m v&#224;o config:</p><pre><code>{

  &#8220;instructions&#8221;: [&#8221;CONTRIBUTING.md&#8221;, &#8220;docs/guidelines.md&#8221;]

}</code></pre><p>AI s&#7869; &#273;&#7885;c v&#224; follow rules trong nh&#7919;ng files n&#224;y.</p><h4>Khi AI code sai</h4><ul><li><p>D&#249;ng `/undo` &#273;&#7875; revert ngay</p></li><li><p>Kh&#244;ng c&#7847;n ho&#7843;ng lo&#7841;n, kh&#244;ng m&#7845;t code</p></li><li><p>Review prompt l&#7841;i: c&#243; &#273;&#7911; context kh&#244;ng? C&#243; r&#245; r&#224;ng kh&#244;ng?</p></li></ul><h4>Ch&#7881; s&#7889; th&#7921;c t&#7871; &#273;&#7875; &#273;o</h4><ul><li><p>&#9989; <strong>S&#7889; l&#7847;n reject AI suggestions</strong> - cao = prompts ch&#432;a r&#245; ho&#7863;c config ch&#432;a &#273;&#250;ng</p></li><li><p>&#9989; <strong>Th&#7901;i gian review code AI generate</strong> - gi&#7843;m d&#7847;n = b&#7841;n v&#224; AI sync &#273;&#432;&#7907;c</p></li><li><p>&#9989; <strong>Bug t&#7915; AI code</strong> - ph&#7843;i = 0 n&#7871;u b&#7841;n review tr&#432;&#7899;c khi merge</p></li></ul><h4>Nh&#7919;ng g&#236; b&#7841;n KH&#212;NG c&#7847;n</h4><ul><li><p>&#10060; Custom commands cho basic workflow</p></li><li><p>&#10060; Edit config li&#234;n t&#7909;c gi&#7919;a Plan/Build (d&#249;ng Tab)</p></li><li><p>&#10060; Ho&#224;n h&#7843;o h&#243;a setup tr&#432;&#7899;c khi d&#249;ng</p></li></ul><h4></h4><div class="pullquote"><h4>S&#7921; th&#7853;t ph&#361; ph&#224;ng</h4><ul><li><p>90% ng&#432;&#7901;i d&#249;ng OpenCode ch&#7881; c&#7847;n: h&#7887;i &#273;&#225;p + Tab (Plan/Build) + <code>/undo</code></p></li><li><p>Config an to&#224;n (<code>permission.ask</code>) &gt; config t&#7889;i &#432;u</p></li><li><p>AI kh&#244;ng &#273;&#7885;c &#273;&#432;&#7907;c business logic trong &#273;&#7847;u b&#7841;n - vi&#7871;t r&#245; ho&#7863;c d&#249;ng <code>instructions</code></p></li><li><p>N&#7871;u AI suggest sai 3 l&#7847;n li&#234;n t&#7909;c &#8594; prompt c&#7911;a b&#7841;n thi&#7871;u context, kh&#244;ng ph&#7843;i l&#7895;i AI</p></li></ul></div><p></p><h3>&#272;i&#7875;m m&#7841;nh th&#7921;c t&#7871; c&#7911;a OpenCode</h3><h4>1. T&#259;ng t&#7889;c &#273;&#7897; th&#7921;c s&#7921;</h4><ul><li><p><strong>Hi&#7875;u r&#245; codebase:</strong> T&#7915; 3 ng&#224;y xu&#7889;ng 30 ph&#250;t (nhanh h&#417;n 90%)</p></li><li><p><strong>T&#236;m bug:</strong> T&#7915; 4 ti&#7871;ng xu&#7889;ng 30 ph&#250;t (nhanh h&#417;n 87% )</p></li><li><p><strong>L&#7853;p k&#7871; ho&#7841;ch feature:</strong> T&#7915; 2 ti&#7871;ng xu&#7889;ng 20 ph&#250;t (nhanh h&#417;n 83% )</p></li></ul><h4>2. T&#7921; tin h&#417;n khi code</h4><ul><li><p>Kh&#244;ng c&#242;n &#8220;m&#7879;t m&#7887;i, nh&#7913;c &#273;&#7847;u to&#224;n t&#7853;p v&#236; ph&#226;n t&#237;ch qu&#225; nhi&#7873;u&#8221;</p></li><li><p>Bi&#7871;t ch&#237;nh x&#225;c ph&#7843;i l&#224;m g&#236;</p></li><li><p>Code review &#237;t l&#7895;i h&#417;n</p></li><li><p>Deploy kh&#244;ng c&#242;n lo l&#7855;ng</p></li></ul><h4>3. H&#7885;c nhanh h&#417;n</h4><ul><li><p>Hi&#7875;u ki&#7871;n tr&#250;c h&#7879; th&#7889;ng nhanh h&#417;n</p></li><li><p>Ph&#225;t hi&#7879;n pattern trong code</p></li><li><p>H&#7885;c t&#7915; codebase l&#7899;n m&#224; kh&#244;ng b&#7883; cho&#225;ng ng&#7907;p</p></li></ul><h4>4. Qu&#7843;n tr&#7883; b&#7857;ng c&#7845;u h&#236;nh</h4><ul><li><p><strong>permission.ask:</strong> m&#7885;i thay &#273;&#7893;i &#273;&#7873;u c&#243; con ng&#432;&#7901;i quy&#7871;t &#273;&#7883;nh</p></li><li><p><strong>instructions:</strong> &#233;p theo ti&#234;u chu&#7849;n n&#7897;i b&#7897;, gi&#7843;m v&#242;ng review</p></li><li><p><strong>c&#244;ng t&#7855;c tools:</strong> b&#7853;t t&#7855;t write/edit &#273;&#7875; chuy&#7875;n gi&#7919;a ch&#7871; &#273;&#7897; ch&#7881; l&#7853;p k&#7871; ho&#7841;ch (Plan-only) v&#224; ch&#7871; &#273;&#7897; x&#226;y d&#7921;ng (Build) nhanh</p></li></ul><p></p><h3>&#272;i&#7875;m y&#7871;u ph&#7843;i bi&#7871;t</h3><h4>1. Kh&#244;ng ph&#7843;i vi&#234;n &#273;&#7841;n ma thu&#7853;t</h4><ul><li><p><strong>Kh&#244;ng vi&#7871;t code thay b&#7841;n:</strong> B&#7841;n v&#7851;n ph&#7843;i hi&#7875;u logic</p></li><li><p><strong>Kh&#244;ng t&#7921; &#273;&#7897;ng fix bug:</strong> Ch&#7881; gi&#250;p t&#236;m nhanh h&#417;n</p></li><li><p><strong>Kh&#244;ng thay th&#7871; t&#432; duy:</strong> V&#7851;n c&#7847;n quy&#7871;t &#273;&#7883;nh thi&#7871;t k&#7871;</p></li></ul><h4>2. &#272;&#432;&#7901;ng cong h&#7885;c t&#7853;p</h4><ul><li><p><strong>M&#7845;t 1-2 tu&#7847;n:</strong> &#272;&#7875; th&#224;nh th&#7841;o commands c&#417; b&#7843;n</p></li><li><p><strong>Ph&#7843;i &#273;&#7885;c docs:</strong> Kh&#244;ng t&#7921; nhi&#234;n nh&#432; ChatGPT</p></li><li><p><strong>C&#7847;n c&#7845;u h&#236;nh:</strong> Ph&#7843;i c&#7845;u h&#236;nh nguy&#234;n t&#7855;c file AGENTS.md cho t&#7915;ng project</p></li></ul><h4>3. Gi&#7899;i h&#7841;n th&#7921;c t&#7871;</h4><ul><li><p><strong>Logic nghi&#7879;p v&#7909; ph&#7913;c t&#7841;p:</strong> V&#7851;n c&#7847;n senior dev gi&#7843;i th&#237;ch</p></li><li><p><strong>Codebase c&#361; qu&#225; l&#7895;i th&#7901;i:</strong> &#272;&#244;i khi AI suggest kh&#244;ng kh&#7843; thi</p></li><li><p><strong>Ki&#7871;n th&#7913;c chuy&#234;n m&#244;n:</strong> Ph&#7843;i h&#7885;c business rules c&#7911;a domain</p></li></ul><p></p><h3>Ch&#7881; s&#7889; th&#7921;c t&#7871; sau 3 th&#225;ng</h3><h4>Tr&#432;&#7899;c vs sau OpenCode:</h4><ul><li><p><strong>Hi&#7875;u feature m&#7899;i:</strong> 2-3 ng&#224;y &#8594; 1/2 ng&#224;y (nhanh h&#417;n 75%)</p></li><li><p><strong>Fix bug ph&#7913;c t&#7841;p:</strong> 4-6 ti&#7871;ng &#8594; 1-2 ti&#7871;ng (nhanh h&#417;n 70%)</p></li><li><p><strong>V&#242;ng code review:</strong> 2-3 rounds &#8594; 1 v&#242;ng (gi&#7843;m 50%)</p></li><li><p><strong>M&#7913;c &#273;&#7897; t&#7921; tin:</strong> 40% &#8594; 85% (t&#259;ng 112%)</p></li></ul><h4>C&#7843;i thi&#7879;n ch&#7845;t l&#432;&#7907;ng:</h4><ul><li><p><strong>T&#7881; l&#7879; bug:</strong> Gi&#7843;m 60% nh&#7901; l&#7853;p k&#7871; ho&#7841;ch t&#7889;t h&#417;n</p></li><li><p><strong>Ch&#7845;t l&#432;&#7907;ng code:</strong> T&#259;ng 40% nh&#7901; pattern nh&#7845;t qu&#225;n</p></li><li><p><strong>Vi&#7871;t t&#224;i li&#7879;u:</strong> Nhanh h&#417;n 3 l&#7847;n</p></li><li><p><strong>L&#224;m vi&#7879;c nh&#243;m:</strong> Hi&#7875;u nhau nhanh h&#417;n</p></li></ul><h3></h3><div class="pullquote"><h3>Th&#7921;c t&#7871; ph&#361; ph&#224;ng: </h3><p><strong>Opencode l&#224; c&#244;ng c&#7909;</strong>, kh&#244;ng ph&#7843;i ph&#233;p thu&#7853;t</p></div><p><strong>&#272;i&#7873;u quan tr&#7885;ng nh&#7845;t t&#244;i h&#7885;c &#273;&#432;&#7907;c</strong></p><ul><li><p>OpenCode khu&#7871;ch &#273;&#7841;i k&#7929; n&#259;ng b&#7841;n &#273;&#227; c&#243;</p></li><li><p>N&#7871;u b&#7841;n y&#7871;u v&#7873; n&#7873;n t&#7843;ng, n&#243; ch&#7881; gi&#250;p b&#7841;n vi&#7871;t code y&#7871;u nhanh h&#417;n</p></li><li><p>N&#7871;u b&#7841;n hi&#7875;u logic nghi&#7879;p v&#7909;, n&#243; gi&#250;p b&#7841;n tri&#7875;n khai nhanh h&#417;n 10 l&#7847;n</p></li></ul><p><strong>K&#7871;t lu&#7853;n th&#7921;c t&#7871;:</strong></p><ul><li><p>Developer gi&#7887;i + OpenCode = Si&#234;u developer</p></li><li><p>Developer y&#7871;u + OpenCode = Developer y&#7871;u nhanh h&#417;n</p></li><li><p>Developer trung b&#236;nh + OpenCode = Developer gi&#7887;i nhanh h&#417;n</p></li></ul><h4>B&#224;i h&#7885;c l&#7899;n nh&#7845;t:</h4><div class="pullquote"><blockquote><p>Kh&#244;ng c&#7847;n h&#7885;c<code>(N)</code>c&#244;ng c&#7909;.<strong> C&#7847;n h&#7885;c &#273;&#250;ng 1 c&#244;ng c&#7909; v&#224; d&#249;ng n&#243; th&#244;ng minh.</strong></p></blockquote></div><h3></h3><h3>K&#7871;t lu&#7853;n: Im l&#7863;ng h&#7885;c, &#273;&#7915;ng im l&#7863;ng ch&#7871;t</h3><p>T&#244;i m&#7845;t 2 n&#259;m &#273;&#7875; hi&#7875;u: </p><div class="pullquote"><blockquote><p>Kh&#244;ng ph&#7843;i AI thay th&#7871; developer.<strong> L&#224; developer kh&#244;ng d&#249;ng AI t&#7921; thay th&#7871; m&#236;nh.</strong></p></blockquote></div><p>B&#7841;n c&#243; 2 l&#7921;a ch&#7885;n:</p><ol><li><p>Ti&#7871;p t&#7909;c l&#224;m th&#7911; c&#244;ng, ti&#7871;p t&#7909;c t&#7909;t l&#7841;i ph&#237;a sau, ti&#7871;p t&#7909;c t&#7921; h&#224;o &#8220;t&#244;i kh&#244;ng d&#249;ng AI&#8221;</p></li><li><p>H&#7885;c 1 tool th&#7921;c t&#7871;, b&#7855;t &#273;&#7847;u t&#7853;n d&#7909;ng AI, v&#224; ti&#7871;n xa h&#417;n &#273;&#7891;ng nghi&#7879;p</p></li></ol><div class="pullquote"><blockquote><p><strong>L&#7921;a ch&#7885;n l&#224; c&#7911;a b&#7841;n</strong>. Nh&#432;ng nh&#7899;: &#8220;<strong>Th&#7901;i gian kh&#244;ng ch&#7901; ai.&#8221;</strong></p></blockquote></div><div><hr></div><div class="preformatted-block" data-component-name="PreformattedTextBlockToDOM"><label class="hide-text" contenteditable="false">Text within this block will maintain its original spacing when published</label><pre class="text">B&#224;i ti&#7871;p theo: &#8220;<strong>C&#224;i OpenCode trong 15 ph&#250;t - Kh&#244;ng c&#7847;n l&#224;m Linux expert</strong>&#8221; - T&#244;i s&#7869; tr&#236;nh b&#224;y step-by-step c&#225;ch setup, v&#7899;i screenshots v&#224; c&#225;c b&#7851;y ph&#7893; bi&#7871;n &#273;&#7875; b&#7841;n kh&#244;ng m&#7845;t 2 n&#259;m nh&#432; t&#244;i.</pre></div><div class="preformatted-block" data-component-name="PreformattedTextBlockToDOM"><label class="hide-text" contenteditable="false">Text within this block will maintain its original spacing when published</label><pre class="text"><strong>C&#226;u h&#7887;i th&#7921;c t&#7871;:</strong> B&#7841;n &#273;ang &#7903; &#273;&#226;u trong h&#224;nh tr&#236;nh n&#224;y? C&#242;n &#273;ang h&#7885;c th&#7911; c&#244;ng hay &#273;&#227; s&#7861;n s&#224;ng t&#7853;n d&#7909;ng AI? Comment xu&#7889;ng d&#432;&#7899;i, t&#244;i mu&#7889;n nghe c&#226;u chuy&#7879;n th&#7853;t t&#7915; c&#7897;ng &#273;&#7891;ng dev Vi&#7879;t.</pre></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://heyhuynhgiabuu.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p><strong>Subscribe &#273;&#7875; kh&#244;ng miss b&#224;i ti&#7871;p theo.</strong> Tin t&#244;i, b&#7841;n kh&#244;ng c&#7847;n m&#7845;t 2 n&#259;m nh&#432; t&#244;i &#273;&#7875; &#273;&#7841;t productivity t&#259;ng 3x.</p>]]></content:encoded></item></channel></rss>