Unlock Your Coding Potential: The Ultimate Guide to Cloth Code

Cloth Code is arguably the most effective coding agent available today. In this article, I'll teach you how to use it, and you don't need to be a professional developer to get started. Having spent well over 200 hours using Cloth Code and studying the "Cloth Code Bible"—an extensive guide by its creator—I've learned that its power is only revealed through hands-on use. There's a reason it's the fastest-growing AI tool in the world. If you want to learn how to use Cloth Code to massively boost your coding ability, make sure to read until the end.

Step 1: Customize Your Setup

The first step in the official guide is to customize your setup. There are several key things you need to do.

Create a cloth.md File

The most basic step is to create a cloth.md file. This is the main system prompt that dictates how Cloth Code behaves. In mine, I include instructions like:

  • Always prioritize writing clean, simple, modular code.
  • Write lots of comments in your code.
  • Adhere to modern UI design principles.

Essentially, this file is the core prompt that defines your agent's personality and coding style. You can even autogenerate this file by typing /init. This command will analyze your existing codebase, learn its structure, and generate a set of high-density instructions for your cloth.md file.

Curate Your Allowed Tools

The next essential step is curating a list of allowed tools in the cloth/settings.json file. This file specifies which commands Cloth Code can run automatically (the allowed list) and which it can never run (the deny list).

By curating this list, you can greatly speed up Cloth Code's workflow, as it won't need to ask for permission for every command it runs.

Install the GitHub CLI

Finally, you should install the GitHub CLI. This allows Cloth Code to interact with GitHub to see pull request details, create new PRs, fetch issues, and more.

On macOS, you can install it with Homebrew: bash brew install gh

On Windows, use the following command: bash winget install --id GitHub.cli

Step 2: Supercharge Cloth Code with More Tools

Cloth Code already has access to your shell environment, but you can make it even more powerful by giving it custom MCPs (Machine-to-Machine Communication Protocols). Cloth Code can act as both an MCP server and a client, allowing it to connect to any number of MCP servers.

Add the Playwright MCP

One MCP that is an absolute must-have is the Playwright MCP. To install it, open your terminal and run this command: bash npm install -g @cloth-code/playwright-mcp After installation, when you type /mcp in Cloth Code, you should see the Playwright MCP listed. This gives the agent the ability to interact with a browser, take screenshots, click buttons, and debug the front end like a professional engineer.

Create Custom Slash Commands

While Cloth Code comes with default commands like /clear and /compact, many users don't realize you can create your own. In your .cloth folder, create a commands subfolder. Inside, you can add markdown files that define custom commands.

For example, I have a create-pr.md command that contains instructions for creating a new pull request. This saves me from retyping the same instructions repeatedly.

Let's walk through creating a new command to fix a GitHub issue.

  1. Create a new file in your .cloth/commands folder named fix-github-issue.md.
  2. Paste the following instructions into the file:
$arguments

Take the following github issue and fix it.
The issue is 

1. Explore the codebase to understand the issue.
2. Create a plan to fix it.
3. Implement the fix.
4. Write tests to verify the fix.
5. Commit the changes.

The $arguments line at the top allows you to pass arguments to your command. In this case, the argument will be the GitHub issue number.

After saving the file, you can launch a new instance of Cloth Code and run your command: /fix-github-issue 1526

This means you can launch an entire workflow of numerous different actions just by typing a single slash command, making you significantly more productive.

Step 3: Master Common Workflows

While you can use Cloth Code in any way you wish, its creators recommend several workflows for best results.

Workflow 1: Explore, Plan, Code, Commit

  1. Explore: Tell Cloth Code to explore the codebase and find all files relevant to the task.
  2. Plan: Switch to "plan mode" by pressing Shift+Tab. In this mode, the agent is more exploratory and focuses on creating an optimal implementation plan. During this stage, you can even instruct it to use sub-agents for specific research tasks (e.g., "launch a sub-agent to figure out the OpenRouter contact in the backend").
  3. Code: Tell the agent to write the code for the feature or bug fix.
  4. Commit: Commit the changes to your repository.

Pro Tip: Use phrases like think, think hard, think harder, and ultra think. These are built-in triggers that increase the "thinking budget" (reasoning tokens) Cloth Code uses before responding, leading to better results for complex problems.

Workflow 2: Test-Driven Development (TDD)

  1. Write Tests: First, instruct Cloth Code to write tests that define the desired behavior and expected outputs. These tests will initially fail because the code hasn't been written yet.
  2. Commit Tests: Commit the failing tests once you're satisfied with them.
  3. Write Code: Tell Cloth Code to write the feature's code, making sure to mention you're using a TDD approach.
  4. Iterate & Commit: Iterate on the code until it passes the tests and you're happy with it, then commit the final feature.

TDD is especially effective for backend APIs, business-critical logic, and library/SDK development. It's less ideal for UI-heavy applications or rapid prototyping where speed is the priority.

Workflow 3: Write Code, Screenshot Results, Iterate

You can drag screenshots directly into the Cloth Code input field (hold Shift). For example, you can screenshot a design you like and ask the agent to build your front end in the same style.

This workflow is powerful because, like humans, the agent's outputs improve significantly with iteration. The first version might be good, but after a few iterations, it will typically look much better.

Workflow 4: Git Operations

Use Cloth Code for all your Git operations. You can create custom commands for creating pull requests, reviewing PRs from other developers, or pushing to GitHub. A simple command can handle staging files, writing commit messages, checking the branch, and pushing—a process that saves tons of time every day. The developers behind Cloth Code use it for the vast majority of their Git interactions.

Step 4: Optimize Your Workflow

Be Specific

The success rate of Cloth Code improves significantly with more specific instructions.

  • Bad Prompt: add tests for file.js
  • Good Prompt: Write a new test file for file.js that uses the Jest testing framework. Add unit tests for the 'calculateTotal' and 'formatCurrency' functions, ensuring you cover edge cases like null inputs and large numbers.

Mention Files Directly

To have the agent work on a specific file, mention it directly using the @ symbol. For example: Look at @components/LeftSidebar.js and tell me how it's structured.

Provide Specific URLs

Cloth Code can browse the web. Instead of copying text from a documentation page, just paste the URL and give it instructions: Implement the tool calling from https://example.com/docs/tool-calling in our backend.

Course Correct Early and Often

If you see the agent going in the wrong direction, press Escape to interrupt it immediately. This prevents it from wasting time on an incorrect path.

Manage Context

Use the built-in /clear and /compact commands to manage the conversation's context. * /clear completely resets the conversation history. * /compact summarizes the conversation to retain the most important information while freeing up context space.

Step 5: Automate with Headless Mode

Cloth Code includes a headless mode for non-interactive contexts like CI/CD pipelines, pre-commit hooks, and other automation scripts. To use it, run Cloth Code with the -p flag followed by your prompt.

cloth -p "Refactor the database connection logic in src/db.js to be more resilient."

You can use this to power automations triggered by GitHub events. For example, you can set up a GitHub Action to have Cloth Code automatically review every pull request, find critical issues, and leave comments.

Note: When using this with GitHub Actions, be sure to customize the system prompt in your cloth.yaml workflow file to ensure the reviews are concise and not overly verbose.

# .github/workflows/cloth.yaml
...
- name: Cloth Code Review
  uses: cloth-code/action@v1
  with:
    system_prompt: |
      You are a senior software engineer reviewing a pull request.
      Focus on critical bugs, security vulnerabilities, and major architectural issues.
      Keep your feedback concise and actionable. Do not comment on style.

You can also use headless mode as an advanced linter to find issues a normal linter would miss, such as typos, stale comments, or misleading variable names.

Step 6: Advanced Multi-Cloth Workflows

Some of the most powerful applications involve running multiple Cloth Code instances in parallel.

Multi-Agent Review Workflow

This multi-step workflow uses separate instances to improve code quality: 1. Use the first Cloth instance to write the initial code. 2. Use /clear to reset the context. 3. Have a second Cloth instance review the first one's work (since it has a separate context, it's like a fresh pair of eyes). 4. Start a third instance (or /clear again). 5. Have this third agent edit the original code based on the feedback from the second agent.

Split-Screen Development

A common practice is to have two Cloth Code instances open side-by-side. You can use the more powerful but slower model (like Opus) for planning on one side, and a faster model (like Sonnet) for execution on the other. You can switch models using the /model command. This allows you to see the file diffs in the terminal as the agent works, so you often don't even need to switch to your editor to see the changes.

The Git Worktree Method

For complex tasks, you can use Git worktrees to check out multiple branches at once and run a separate Cloth Code instance in each. 1. Create a worktree: git worktree add ../my-feature-branch 2. cd into the new directory and launch Cloth Code. 3. Repeat for as many parallel branches as you need.

Debugging Tip: When launching a new instance, you can use the --verbose flag (cloth --verbose) to see a more detailed output of what the agent is doing. This is useful for debugging but not practical for everyday use.