Six Workflows That Make AI-Generated Code Actually Correct
Hello everyone, I'm Brother Er.
I've noticed that in the group chats, comment sections, and private messages, the two most frequently asked questions about Claude Code are: How exactly do you use Claude Code? And how do you guarantee the code it writes is correct?
The first question is easy to answer: just install it and you're good to go.
You can even use PaiSwitch to switch to any underlying model (open-source). It just upgraded yesterday, adding a desktop version.
The second question requires a longer discussion.
Today, I'm going to condense the experience I've gathered into 6 practical Cases. Each Case includes specific prompts, the execution process, and the final results. You'll understand after reading through them.
TIPS: Claude just upgraded to the Fable 5 model today. The AI community is buzzing that this model surpasses GPT-5.5. Have you tried it yet?
Oh, and you can use it by upgrading Claude to the latest version.
01. CLAUDE.md is Extremely Important
Many friends jump straight into coding with Claude Code right after installation.
But my experience is that the first step should be writing a CLAUDE.md file.
CLAUDE.md is a project-level instruction file for Claude Code, placed in the project root directory. Claude Code automatically loads it at the start of every new session. You can think of it as writing a "new employee onboarding manual" for Claude Code, where you need to specify the project's tech stack, coding standards, directory structure, and forbidden commands.
Case1: Adding a /export command to PaiCLI
I used PaiCLI for this comparison.
PaiCLI is a Java Agent CLI that rivals Claude Code.
Test prompt:
Add a /export command to PaiCLI that exports the current session's conversation history into a Markdown file, saved to the ~/.paicli/exports/ directory.
Without PAI.md, the model only receives the user's sentence and the code files it reads itself as context.
With PAI.md, PaiCLI injects the content of PAI.md into the system prompt upon startup.
Let's look at the execution result of the /export command.
Start a new session, enter a random prompt. Then execute the /export command.
Then let's look at the content of the exported Markdown file.
The content inside PAI.md is shown below.
In other words, even though we only sent a very simple message when using the Agent, the system instructions already have a lot of context stuffed into them because of the Harness.
This includes descriptions of Skills, MCP tools, and so on.
This is also a reminder: your Agent doesn't need to install too many global Skills and MCP tools. They are very likely to be noise in the context.
It's best to configure them on a per-project basis.
02. Building a 3D Interactive Page with PaiCLI
The most visually impactful tasks are frontend and 3D. Let's use a Three.js task to demonstrate PaiCLI's code generation capabilities.
The reason I didn't use Claude Code directly is that this level of case doesn't require it yet, haha.
It's also a good chance to prove PaiCLI's capabilities.
Case2: Three.js Starry Sky Particle Interaction Page
The prompt is as follows.
Use Three.js to write a starry sky particle interaction page. Requirements: 1) 3000 particles randomly distributed within a spherical space, with particle colors transitioning (blue-purple-pink); 2) When the mouse moves, surrounding particles are "attracted" towards the cursor position, creating a ripple effect; 3) The background is a dark gradient, with a line of glowing text "Built with PaiCLI" at the bottom; 4) Supports touch interaction on mobile devices; 5) Output a complete HTML file that can be opened directly in a browser.
The result produced by DeepSeek V4 Pro shows that the particle color gradients are very natural, moving the mouse indeed creates a ripple effect, and touch interaction on mobile works normally.
Tip: How to Write Prompts for Visual Tasks
There's a pattern to prompts for visual tasks—separate "what you see" from "what the interaction does."
First describe the static visuals (particle colors, background color, text style), then describe the dynamic interactions (mouse movement effects, click behavior, animations).
Claude Code/Codex handles this kind of structured description very well.
03. Skills Turn PaiCLI into an Expert
Skills are "professional knowledge packs" for Claude Code. After installing the corresponding Skill, Claude Code becomes more professional and accurate when handling tasks in specific domains.
For ease of demonstration, we'll still use PaiCLI here to show the power of Skills. PaiCLI also supports Skills, and the installation method is the same as Claude Code.
Case: Using the web-access Skill for Competitive Research
The prompt is as follows.
Use web-access to help me research the two AI workflow platforms Dify and FastGPT, focusing on node types, model access methods, and whether they support private deployment. Organize the findings into a comparison table.
Without web-access, PaiCLI might just use WebSearch a few times and call it a day, providing information with little depth.
But with web-access, it's a completely different story.
The information density of the comparison table is very high.
Tip: Installing and Managing Skills
Installing a Skill is very simple; just tell Claude Code to install it. For example:
Help me install the web-access skill, the repository address is https://github.com/eze-is/web-access
The installed Skill files are stored in the project's .claude/skills/ directory. Each Skill has a SKILL.md main file that defines the instruction logic, and can also have a references/ directory for reference documents. We can also write our own Skills; the format is just a Markdown file with a YAML header.
It is recommended to install and configure Skills for each project individually, not globally, because global installation consumes a lot of context.
04. Hooks—Deterministic Rules as a Safety Net for Probabilistic Models
The CLAUDE.md and Skills discussed earlier are both "prompt-level constraints"—essentially telling the model "what to do" within the system prompt.
Hooks are different. They are code-level interceptions that run outside the model. Once you set a rule, it executes every time, with no randomness.
As an analogy, CLAUDE.md is like the verbal rules you give a new employee: "Our team's code is not allowed to use MD5 encryption." The new employee will comply most of the time, but might forget when busy. A Hook is like an automated check on the CI/CD pipeline; if the code uses MD5, it simply won't compile, regardless of whether you forgot.
Three Trigger Timings
Hooks support three timings:
- PreToolUse—Triggers before the model calls a tool. Suitable for security interception, such as detecting a
git pushthat is about to commit a.envfile and directly rejecting it, without needing the model to judge. - PostToolUse—Triggers after a tool finishes executing. Suitable for quality checks, such as automatically running
mvn compileafter writing a Java file. If compilation fails, the error information is fed back to the model, which automatically fixes it and recompiles. - Stop—Triggers when the session ends. Suitable for state persistence, such as automatically saving key decisions from the current session to a log, so context can be automatically restored when a new session starts next time.
Configuration Method
Hooks are configured in .claude/settings.json. A compile-check Hook for a Java backend project looks like this:
{
"hooks": {
"afterWrite": [
{
"pattern": "**/*.java",
"command": "mvn compile -q 2>&1 | tail -20"
}
]
}
}
For a frontend project, you can change the command to eslint --fix; for a Python project, change it to pytest -x.
The principle is the same—automatically run a verification after the tool executes. If it fails, feed the error back to the model, which fixes it and triggers the verification again, looping until it passes.
05. Fable 5 Creates a Promotional PPT for PaiCLI
Just today, Anthropic released Claude Fable 5, a model hailed as god-like by the AI community.
You can see it by updating the Claude desktop app to the latest version. The usage deadline is June 22nd.
What Makes Fable 5 Strong
Let's skip the benchmarks and go straight to a practical test.
Prompt:
I want to design a promotional PPT for the PaiCLI project, using this Skill: https://github.com/op7418/guizang-ppt-skill
Basic project info: An Agent CLI similar to Claude Code
Target audience: 2027 graduates, students who want to learn about Agents
Brand tone: Warm and healing, naturally relaxed, cool on the outside but warm on the inside, with a sense of story
You can use whatever is available in the codebase (not all materials need to be used). I just need the final delivered PPT to have top-tier aesthetics, making people want to learn it immediately upon seeing it.
The Claude desktop app will first fetch the Guizang PPT Skill, simultaneously understand the PaiCLI project materials, and then create the promotional PPT according to the Skill's methodology.
The overall token consumption is acceptable.
Pro and Max users can use it for free before June 22nd. I suggest everyone try it during this window.
I'll take a screenshot so you can see the effect. Overall, I think it's quite nice, and the project's key points were captured.
06. Context Management and Prompt Principles
Claude Code's context window is limited. As a session grows longer, earlier conversations are automatically compressed, and previous details may be lost.
This means context is the Agent's most expensive resource.
"Don't install too many global Skills and MCP tools" is essentially about managing context overhead—every extra Skill description and every extra MCP tool definition consumes the context budget.
Several coping principles:
- Break complex tasks into independent sub-tasks, and do each sub-task in a new session.
- Write key project information in CLAUDE.md; it loads automatically each time and won't be lost due to compression.
- When you feel the model is starting to "forget things," manually execute
/compactto trigger compression, retaining recent conversations and key decisions while clearing early redundancy.
A good prompt contains three elements:
- Operation Target—Which file, which piece of code
- Operation Action—Modify, delete, add, refactor
- Verification Method—Run tests, compile, manual confirmation
When all three elements are present, the execution accuracy rate is much higher.
Ultimately, the core competitiveness in the AI programming era isn't how strong the model is, but whether you can combine the model's capabilities with engineering tools to form a repeatable, verifiable workflow.
【Tools don't become powerful on their own; it's the way you wield them that makes them powerful.】
See you next time.
Top 3 from juejin.cn, machine-translated. The original thread is authoritative.
You can't use other LLM APIs with the Claude Code desktop version, right?
Well written.
666666