Restructure CLAUDE.md for better agent adherence by adding <important if> conditional blocks. Separates foundational content (always relevant) from task-specific instructions (wrapped in conditional tags). Preserves <!-- BEGIN FLUX --> markers. Triggers: /flux:improve-claude-md.
From fluxnpx claudepluginhub nairon-ai/flux --plugin fluxThis skill uses the workspace's default tool permissions.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
Restructure a CLAUDE.md file so Claude actually follows the instructions. Applies the <important if="condition"> pattern to task-specific sections while keeping foundational content unwrapped.
Why: Legacy Claude environments wrap CLAUDE.md in a <system_reminder> that says contents "may or may not be relevant." Long flat files cause the model to treat individual sections as optional. Conditional blocks give a clearer signal about when to apply specific instructions.
Full request: $ARGUMENTS
Accepts:
On entry, set the session phase:
PLUGIN_ROOT="${DROID_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}}"
[ ! -d "$PLUGIN_ROOT/scripts" ] && PLUGIN_ROOT=$(ls -td ~/.claude/plugins/cache/nairon-flux/flux/*/ 2>/dev/null | head -1)
FLUXCTL="${PLUGIN_ROOT}/scripts/fluxctl"
$FLUXCTL session-phase set improve-claude-md
On completion, reset to idle:
$FLUXCTL session-phase set idle
CLAUDE.md, then .claude/CLAUDE.md)Scan the file and classify each section into one of two buckets:
Foundational (never wrap):
<!-- BEGIN FLUX --> ... <!-- END FLUX --> block (preserve as-is — this is already managed by flux-setup)Task-specific (candidates for wrapping):
<important if="you are writing or modifying tests"><important if="you are writing API routes, endpoints, or server actions"><important if="you are modifying database schemas, queries, or migrations"><important if="you are deploying, configuring CI/CD, or managing infrastructure"><important if="you are handling authentication, authorization, or secrets"><important if="you are writing CSS, styling components, or working on UI"><important if="you are optimizing performance or configuring caching"><important if="you are writing or updating documentation">Produce a rewritten version that:
<important if="condition"> blocks<!-- BEGIN FLUX --> / <!-- END FLUX --> markers exactlyShow the user a diff-style preview of the changes:
Use AskUserQuestion to confirm:
{
"questions": [{
"question": "Here's the restructured CLAUDE.md. The task-specific sections are now wrapped in <important if> blocks so Claude applies them more reliably. Apply these changes?",
"header": "Apply",
"multiSelect": false,
"options": [
{
"label": "Yes — apply the restructured version",
"description": "Replaces CLAUDE.md with the version using conditional blocks. All content is preserved, just restructured."
},
{
"label": "No — keep the current version",
"description": "No changes made."
}
]
}]
}
If approved:
If declined:
<!-- BEGIN FLUX --> block contents (managed by flux-setup)<important if="tests"> and <important if="test fixtures"> separately)<important if> blocks are already present, preserve and potentially expand them# MyProject
Use pnpm. Node 20+.
## Testing
- Use `createTestApp()` for integration tests
- Mock database with `dbMock` from `packages/db/test`
- Test fixtures live in `__fixtures__/` directories
## API Conventions
- All endpoints return `{ data, error }` shape
- Validate auth tokens in middleware
- Use zod for request validation
## Deployment
- Run `pnpm build` before deploying
- Set DATABASE_URL in production
- Never deploy on Fridays
# MyProject
Use pnpm. Node 20+.
<important if="you are writing or modifying tests">
## Testing
- Use `createTestApp()` for integration tests
- Mock database with `dbMock` from `packages/db/test`
- Test fixtures live in `__fixtures__/` directories
</important>
<important if="you are writing API routes or server actions">
## API Conventions
- All endpoints return `{ data, error }` shape
- Validate auth tokens in middleware
- Use zod for request validation
</important>
<important if="you are deploying or configuring CI/CD">
## Deployment
- Run `pnpm build` before deploying
- Set DATABASE_URL in production
- Never deploy on Fridays
</important>