All articles
Tonis Tiganik--6 min read

Building Custom Agent Workflows with .cwt Directories

Create project-based agent configurations, chain jobs together, and build reproducible AI workflows.

Building Custom Agent Workflows with .cwt Directories

Why Does Context Matter for AI Agent Workflows?

A bare prompt works fine for one-off tasks. Ask Claude Code to rename a variable, fix a type error, write a test - no special setup needed. But the moment your task depends on project conventions, deployment targets, API keys, or coordination between multiple agents, a bare prompt falls short.

Consider a deploy job. The agent needs to know which branch to build, where the artifacts go, what secrets to use, and what post-deploy checks to run. You could paste all of that into the prompt every time, but that's fragile and repetitive. A CLAUDE.md file in your repo helps, but it mixes agent-specific workflow instructions with general project context that human developers also read.

ClawTab's .cwt/ directory gives you a dedicated place for agent workflow configuration - separate from your codebase documentation, versioned alongside your project, and automatically wired into every job run. Each job gets its own subfolder with its own instructions, while shared context lives at the root level where every job can access it.

What Is the .cwt Directory Structure?

The .cwt/ directory lives at the root of your project, next to your src/, package.json, or Cargo.toml. Inside it, each job gets its own subfolder. Here's what a typical setup looks like:

myproject/
  .cwt/
    cwt.md              # shared context for all jobs (you write this)
    browse.sh           # auto-generated Safari automation helper
    send.sh             # auto-generated Telegram send helper
    deploy/
      job.md            # deploy-specific prompt (you write this)
      cwt.md            # auto-generated per-job context
    lint/
      job.md            # lint-specific prompt (you write this)
      cwt.md            # auto-generated per-job context
    review/
      job.md
      cwt.md

There are two files you write yourself and one that ClawTab generates:

  • .cwt/cwt.md (root level) - shared context available to every job in the project. Write project-wide conventions, architecture notes, and common instructions here.
  • .cwt/{job-name}/job.md - the prompt and instructions for one specific job. This is where you describe what the job should do.
  • .cwt/{job-name}/cwt.md - auto-generated by ClawTab on save, settings change, or app startup. Contains job-specific metadata, tool references, and environment details.

If you don't set a job_name, ClawTab defaults to "default", placing files at .cwt/default/job.md.

Writing Shared Context in cwt.md

The root .cwt/cwt.md file is your project's shared context - the information every job in this project needs regardless of what it's doing. Think of it as a CLAUDE.md scoped specifically to your automated workflows.

Good shared context includes:

  • Project architecture - where the source lives, what the build system is, which directories matter
  • Conventions - coding style, commit message format, branch naming, test expectations
  • Environment details - which runtime version, which package manager, paths to config files
  • Common constraints - "never modify files in vendor/", "always run tests before committing", "use pnpm, not npm"

Here's an example for a TypeScript monorepo:

# Project context

- Monorepo: pnpm workspaces
- Packages: apps/web (Next.js), apps/api (Fastify), packages/shared
- Build: pnpm turbo build
- Test: pnpm turbo test
- Lint: pnpm biome check --write
- Node 22, TypeScript strict mode
- Never edit generated files in dist/ or .next/
- Commit messages: imperative mood, no prefix

Keep it concise. The agent reads this on every run, so avoid verbose explanations. State facts, not tutorials.

Writing Job-Specific Instructions in job.md

Each job's job.md is the actual prompt - the task description that tells the agent what to do. This is where you get specific.

A deploy job might look like this:

# Deploy to staging

1. Pull latest from main
2. Run the full test suite: pnpm turbo test
3. If tests pass, build all packages: pnpm turbo build
4. Deploy apps/web to Vercel: vercel --prod
5. Deploy apps/api: docker build -t api . && docker push registry.example.com/api:latest
6. Run smoke tests: curl -f https://staging.example.com/health
7. Post results to Telegram using send.sh

A lint/fix job could be much simpler:

# Lint and fix

Run biome check --write on the entire codebase.
If there are unfixable errors, list them and stop.
If everything passes, commit the changes with message "fix: auto-lint".

The job.md content is passed directly to Claude Code as the prompt. ClawTab also includes it via an @ file reference so Claude has both the file context and the inline instructions. You can use markdown, numbered steps, conditional logic, references to other files in the project - anything you'd put in a Claude Code prompt.

What Does ClawTab Auto-Generate?

When you save a Folder job or start the ClawTab desktop app, it generates (or regenerates) the per-job .cwt/{job-name}/cwt.md file. This auto-generated file contains metadata that changes between runs or depends on your ClawTab configuration:

  • Job name and identifier
  • Available helper scripts (browse.sh for Safari automation, send.sh for Telegram messaging)
  • Environment variable names that will be available at runtime
  • References to the shared context file

ClawTab also generates the helper scripts at the root .cwt/ level. browse.sh wraps Safari automation so your agent can fetch web pages, and send.sh wraps Telegram messaging so your agent can post status updates mid-run (if you have Telegram configured).

When a Folder job runs, ClawTab assembles everything into a single Claude Code invocation:

cd /projects/myapp && claude $'@.cwt/cwt.md @.cwt/deploy/cwt.md @.cwt/deploy/job.md\n\n<job.md content>'

The @ references tell Claude Code to read those files as context. The job.md content is also included inline as the prompt. The working directory is the project root (parent of .cwt/), not the .cwt/ directory itself, so all file paths in your instructions are relative to the project.

Secrets are injected as tmux environment variables - they never appear in the command string or in any file.

How Do You Run Multiple Jobs in the Same Project?

A single .cwt/ directory can hold as many jobs as you need. Each job is a subfolder with its own job.md and auto-generated cwt.md. All of them share the root .cwt/cwt.md context.

In ClawTab, you create multiple Folder jobs pointing to the same .cwt/ path but with different job_name values:

# Job 1: deploy
job_type: folder
folder_path: /projects/myapp/.cwt
job_name: deploy

# Job 2: lint
job_type: folder
folder_path: /projects/myapp/.cwt
job_name: lint

# Job 3: review
job_type: folder
folder_path: /projects/myapp/.cwt
job_name: review

Each job runs in its own tmux pane. ClawTab groups them under the same tmux window (named cwt-myapp), splitting panes when a window already exists. This means you can run deploy, lint, and review simultaneously as parallel agents - each with their own instructions but sharing the same project context.

This pairs well with agent swarms. Instead of running multiple copies of the same task, you run different specialized agents that each handle one aspect of your workflow.

Combining .cwt Workflows with Cron Scheduling

Folder jobs support cron scheduling just like any other ClawTab job. This turns your .cwt/ configurations into recurring automated workflows.

Common patterns:

  • Nightly lint pass - schedule a lint job for 2am every night. The agent runs biome/eslint, fixes what it can, and commits the result.
  • Morning dependency review - a job that checks for outdated packages, reviews changelogs, and opens PRs for safe updates.
  • Post-deploy smoke tests - trigger a test job after each deploy to verify the staging environment.
  • Weekly code review - an agent that reviews the week's PRs and posts a summary to Telegram.

Because the instructions live in job.md files and the shared context in cwt.md, updating the workflow is just editing a markdown file. No pipeline YAML, no CI configuration language - just plain instructions the agent reads on every run.

Pair cron-triggered jobs with auto-yes mode to let them run completely unattended. The agent launches on schedule, ClawTab auto-accepts permission prompts, and you get a Telegram notification when it finishes.

.cwt Directories vs Bare Prompts vs CLAUDE.md

There are three ways to give Claude Code project context. Each serves a different purpose:

Bare promptCLAUDE.md.cwt directory
ScopeSingle runAll Claude Code sessions in the repoClawTab jobs in this project
PersistenceNoneVersioned in repoVersioned in repo
AudienceOne-off taskEvery developer + every agentAutomated agent workflows only
Per-job instructionsInline in promptNot supportedSeparate job.md per job
Shared contextCopy-pasteAutomaticAutomatic via cwt.md
Auto-generated metadataNoNoYes (helper scripts, env, tools)
Cron supportNoNoYes
Secret injectionManual exportNoAutomatic via tmux env

Use CLAUDE.md for general project conventions that benefit both human developers and ad-hoc Claude Code sessions. Use .cwt/ for structured, repeatable agent workflows that run on a schedule or are triggered from ClawTab. The two complement each other - your CLAUDE.md might say "use pnpm" and your .cwt/deploy/job.md says "run pnpm turbo build and deploy to Vercel".

For one-off tasks, a bare prompt is still the right tool. Don't over-engineer a .cwt/ directory for something you'll run once.

Real-World Workflow Examples

Here are four .cwt/ configurations for common development workflows:

Deploy

# .cwt/deploy/job.md
Pull main, run tests, build, and deploy to staging.
If any step fails, stop and report the error via send.sh.
On success, run smoke tests against staging and report results.

Lint and fix

# .cwt/lint/job.md
Run biome check --write on the entire codebase.
Commit any changes with message "fix: auto-lint".
If there are unfixable errors, list them in a Telegram message.

Code review

# .cwt/review/job.md
Find all PRs merged to main in the last 24 hours.
For each PR, review the diff for:
- Security issues (exposed secrets, SQL injection, XSS)
- Performance regressions (N+1 queries, missing indexes)
- Missing tests for new functionality
Post a summary to Telegram with findings per PR.

Test suite

# .cwt/test/job.md
Run the full test suite: pnpm turbo test
If any tests fail:
1. Read the failing test and the code it tests
2. Determine if the test is wrong or the code is wrong
3. Fix whichever is incorrect
4. Re-run the failing tests to confirm the fix
5. Commit with message "fix: repair failing tests"

Each of these shares the same root .cwt/cwt.md for project conventions, uses injected secrets for API tokens, and can be triggered manually from ClawTab or on a cron schedule.

Frequently Asked Questions

A .cwt directory is a project-level configuration folder that holds agent workflow definitions for ClawTab's Folder job type. It contains a shared context file (cwt.md) at the root and subfolders for each job, where each subfolder has a job.md file with task-specific instructions and an auto-generated cwt.md with metadata. The directory lives at the root of your project alongside your source code.

Create a .cwt/ folder at your project root. Add a cwt.md file with shared project context (architecture, conventions, constraints). Then create a subfolder for each job (e.g., .cwt/deploy/, .cwt/lint/) and write a job.md file in each one with the task-specific instructions. In ClawTab, create a Folder job pointing to your .cwt/ path with the corresponding job_name. ClawTab auto-generates the remaining files on save.

The root .cwt/cwt.md is a file you write yourself containing shared context for all jobs in the project - things like project architecture, coding conventions, and build commands. The per-job .cwt/deploy/cwt.md is auto-generated by ClawTab and contains job-specific metadata like available helper scripts, environment variables, and tool references. Both are passed to Claude Code as context when the job runs.

Yes. Create multiple Folder jobs in ClawTab that point to the same .cwt/ directory but with different job_name values. Each job runs in its own tmux pane, and ClawTab groups them under the same tmux window. You can run deploy, lint, and review agents in parallel, each with their own instructions but sharing the same project context.

ClawTab changes to the project root (the parent of .cwt/), then runs Claude Code with @ file references to the shared context, per-job context, and job instructions: cd /project && claude $'@.cwt/cwt.md @.cwt/deploy/cwt.md @.cwt/deploy/job.md\n\n<job.md content>'. Secrets are injected as tmux environment variables, never in the command string.

Use both - they serve different purposes. CLAUDE.md is for general project conventions that benefit both human developers and ad-hoc Claude Code sessions. The .cwt/ directory is for structured, repeatable agent workflows that run on a schedule or are triggered from ClawTab. Your CLAUDE.md might say 'use pnpm' while your .cwt/deploy/job.md says 'run pnpm turbo build and deploy to Vercel'.

Yes. ClawTab Folder jobs support cron scheduling just like any other job type. Set a cron expression on your Folder job and it will run on schedule. Combine this with auto-yes mode to let the agent run completely unattended - it launches on schedule, ClawTab auto-accepts permission prompts, and you get a notification when it finishes.

Related Articles