Get the FREE Ultimate OpenClaw Setup Guide →

claude-exec

npx machina-cli add skill dceoy/ai-coding-agent-skills/claude-exec --openclaw
Files (1)
SKILL.md
2.9 KB

Claude Exec Skill

Use Claude Code CLI to execute development tasks that involve code modifications. This skill modifies code.

When to Use

  • User asks to "add", "create", "implement", or "generate" code
  • User wants to refactor existing code
  • User needs to fix a bug
  • User wants to create tests
  • User asks to "update" or "modify" code

Prerequisites

Verify Claude Code CLI is available:

claude --version  # Should display installed version

Basic Usage

Step 1: Understand the Task

Parse what needs to be done:

  • What to create/modify?
  • Which files are affected?
  • Expected outcome?
  • Constraints or requirements?

Step 2: Gather Context

Before executing, understand the current state:

git status
git diff

Read relevant files to follow existing patterns.

Step 3: Execute Claude Code

Run Claude Code with clear instructions (use -p/--print to output once and exit):

claude -p "[TASK]

Follow these guidelines:
- Follow existing code patterns and conventions
- Add appropriate error handling
- Include necessary imports
- Maintain readability and code quality
- Add comments only for complex logic

Do NOT change unrelated files."

If your CLI does not support -p, run claude and paste the prompt.

Step 4: Verify Changes

After execution:

git status
git diff

Run relevant checks or tests if available.

Step 5: Report Results

Provide:

  • Files modified/created
  • Summary of changes
  • Verification results
  • Any issues or warnings

Example Tasks

claude -p "Add email validation to ContactForm.tsx:
- Use regex: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/
- Show error message below input field
- Validate on blur and submit
- Prevent submission if invalid
- Style error message in red (#dc2626)
Follow existing form validation patterns."
claude -p "Refactor validation logic in src/components/LoginForm.tsx:
- Extract validation into src/utils/validation.ts
- Create validateEmail and validatePassword functions
- Keep existing behavior
- Add TypeScript types"

Best Practices

  • Be specific in task descriptions (paths, requirements, constraints)
  • Review all changes with git diff
  • Run lint/tests when available
  • Avoid auto-approving risky changes

Error Handling

  • If execution fails, tighten scope and re-run
  • If changes are incorrect, revert and re-run with clearer guidance
  • If tests fail, fix failures before reporting success

Related Skills

  • claude-ask for understanding code before modifying
  • claude-review for reviewing changes after modification

Limitations

  • Cannot run tests by itself
  • May miss project-specific constraints
  • Requires manual verification

Source

git clone https://github.com/dceoy/ai-coding-agent-skills/blob/main/skills/claude-exec/SKILL.mdView on GitHub

Overview

Claude Exec uses the Claude Code CLI to perform code generation, refactoring, feature work, bug fixes, and test creation. It emphasizes following project patterns, adding necessary imports and error handling, and verifying changes via Git before reporting results.

How This Skill Works

When a task is provided, the agent parses the scope and affected files, checks the repo state with git status and git diff, then runs Claude Code CLI with a structured prompt using claude -p. After execution, it reviews the changes with git status/git diff, and runs relevant checks or tests if available before reporting results.

When to Use It

  • User asks to add, create, implement, or generate code
  • User wants to refactor existing code
  • User needs to fix a bug
  • User wants to create tests
  • User asks to update or modify code

Quick Start

  1. Step 1: Understand the Task - determine what to create/modify, affected files, constraints
  2. Step 2: Gather Context - check repo state with git status/git diff and read relevant files
  3. Step 3: Execute Claude Code - run claude -p with clear task instructions and follow guidelines; if -p unsupported, run claude and paste prompt

Best Practices

  • Be specific in task descriptions with file paths, requirements, and constraints
  • Follow existing code patterns and conventions
  • Review changes with git diff and run lint/tests when available
  • Add error handling and necessary imports; maintain readability and code quality
  • Verify results and be prepared to revert or re-run with clearer guidance

Example Use Cases

  • Add email validation to ContactForm.tsx: use regex, show error message below input, validate on blur and submit, prevent submission if invalid, and style the error in red
  • Refactor validation logic in src/components/LoginForm.tsx: extract into src/utils/validation.ts, create validateEmail and validatePassword functions, keep existing behavior, and add TypeScript types
  • Generate unit tests for a module to improve coverage
  • Implement a new feature by adding an API integration in a service file
  • Update error handling and imports after a codebase change while preserving existing behavior

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers