<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Ai-Coding-Practice on KnightLi Blog</title>
        <link>https://knightli.com/en/tags/ai-coding-practice/</link>
        <description>Recent content in Ai-Coding-Practice on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Fri, 20 Mar 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://knightli.com/en/tags/ai-coding-practice/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>How to Use Codex in VS Code (From Setup to Efficient Real-World Workflow)</title>
        <link>https://knightli.com/en/2026/03/20/how-to-use-codex-in-vs-code/</link>
        <pubDate>Fri, 20 Mar 2026 00:00:00 +0000</pubDate>
        
        <guid>https://knightli.com/en/2026/03/20/how-to-use-codex-in-vs-code/</guid>
        <description>&lt;p&gt;Codex can help you write code, fix bugs, understand projects, and run commands directly from the VS Code sidebar.&lt;/p&gt;
&lt;h2 id=&#34;1-preparation&#34;&gt;1. Preparation
&lt;/h2&gt;&lt;p&gt;Before you start, make sure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;VS Code is updated to a recent stable version.&lt;/li&gt;
&lt;li&gt;You can access OpenAI services normally.&lt;/li&gt;
&lt;li&gt;Your project is opened locally (preferably in a Git repository).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;2-install-the-extension&#34;&gt;2. Install the Extension
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;Open the VS Code Extensions panel.&lt;/li&gt;
&lt;li&gt;Search and install: &lt;code&gt;Codex - Codex - OpenAI&#39;s coding agent&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Complete the sign-in/authorization flow.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;3-open-the-codex-sidebar&#34;&gt;3. Open the Codex Sidebar
&lt;/h2&gt;&lt;p&gt;You can open it in either way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Click &lt;code&gt;Open Codex Sidebar&lt;/code&gt; in the top-right area of the editor.&lt;/li&gt;
&lt;li&gt;Use Command Palette (&lt;code&gt;Ctrl + Shift + P&lt;/code&gt;), search &lt;code&gt;Codex&lt;/code&gt;, and open it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After opening, Codex reads the current workspace context and becomes ready for chat.&lt;/p&gt;
&lt;h2 id=&#34;4-common-usage-patterns&#34;&gt;4. Common Usage Patterns
&lt;/h2&gt;&lt;h3 id=&#34;41-ask-it-to-explain-code&#34;&gt;4.1 Ask It to Explain Code
&lt;/h3&gt;&lt;p&gt;Example prompt:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Please explain the core logic of this file,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;and point out the 3 areas most likely to fail.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Great for quickly understanding legacy code.&lt;/p&gt;
&lt;h3 id=&#34;42-ask-it-to-implement-features&#34;&gt;4.2 Ask It to Implement Features
&lt;/h3&gt;&lt;p&gt;Example prompt:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Add a /healthz endpoint to the existing API.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;It should return app version and database connectivity status,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;and include basic tests.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;If you clearly state constraints and acceptance criteria, output quality is usually much more stable.&lt;/p&gt;
&lt;h3 id=&#34;43-ask-it-to-fix-issues&#34;&gt;4.3 Ask It to Fix Issues
&lt;/h3&gt;&lt;p&gt;Example prompt:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;This endpoint intermittently returns 500 under concurrency.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;First identify the root cause, then propose a minimal-change fix,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;and finally list regression test points.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;“Diagnose first, then fix” helps reduce accidental over-refactoring.&lt;/p&gt;
&lt;h2 id=&#34;5-high-quality-prompt-template&#34;&gt;5. High-Quality Prompt Template
&lt;/h2&gt;&lt;p&gt;You can reuse this template directly:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Background: This is a &amp;lt;tech stack&amp;gt; project. Current goal: &amp;lt;goal&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Constraints: Do not modify &amp;lt;module/interface&amp;gt;; keep compatibility with &amp;lt;version/platform&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Output:
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;1) File list to change
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;2) Key code explanation
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;3) Validation steps
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;4) Risks and rollback plan
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This is especially useful for large projects and team collaboration.&lt;/p&gt;
&lt;h2 id=&#34;6-faq&#34;&gt;6. FAQ
&lt;/h2&gt;&lt;h3 id=&#34;61-about-free-quota&#34;&gt;6.1 About Free Quota
&lt;/h3&gt;&lt;p&gt;Type &lt;code&gt;\&lt;/code&gt; in the input box, then choose status to view quota/reset-time related information.&lt;/p&gt;
&lt;h3 id=&#34;62-changes-are-not-as-expected&#34;&gt;6.2 Changes Are Not as Expected
&lt;/h3&gt;&lt;p&gt;After changes are generated, open the review panel to inspect details.
If not satisfied, use undo/revert.
You can split large requirements into smaller steps and execute incrementally.
Use Git and keep small commits for easier rollback.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
