Formulas

Básico

AI Writing Cleanup

Detect and remove AI writing patterns from text using Wikipedia's Signs of AI Writing as a live reference.

Prompt

Use the Dagu skill to create an AI writing cleanup workflow. Refer to the schema, coding agent, and pitfalls references for correct syntax. Ask the user: - Do they want to process a file or paste text inline? (support both input_file and input_text params) - How many rewrite rounds? (default: 2) - Strictness level? (low/medium/high, default: medium) Prerequisites: at least one AI coding agent CLI installed (claude or gemini). curl for fetching the Wikipedia reference. The workflow has 4 steps: detect_agent, setup, review_loop, finalize. Step 1 — detect_agent: Output the full binary path (not just the name) since Dagu scripts may not have the user's full PATH. Check common locations like ~/.local/bin/ as fallback. Add PATH: "${HOME}/.local/bin:${PATH}" to top-level env. Step 2 — setup: - Fetch the latest Wikipedia "Signs of AI Writing" page (raw wikitext) via curl. The URL should be a top-level env variable so users can swap it. - Prepare the input text. For input_file, cp it. For input_text, use `printenv input_text` to safely write it to a file — do NOT use ${input_text} directly in scripts because Dagu expands variables before the shell runs. See the printenv pitfall. - Write all multiline/user-controlled env vars (WRITING_STYLE, ADDITIONAL_RULES, CHECK_STRICTNESS) to helper files with a common prefix in DAG_DOCS_DIR. These files are read by the loop step and cleaned up in finalize. Step 3 — review_loop: A single script step with a bash for loop (NOT repeat_policy, NOT a sub-DAG). The loop runs up to max_rounds iterations: a. Build a prompt with the wiki reference, style (from file), strictness (from file), and current text. Use a single-quoted heredoc delimiter (<<'INSTR') for the system instructions so shell doesn't expand them. b. Call the AI agent (CHECK_MODEL, e.g. sonnet) to check text. First line of output: issue count. Remaining lines: per-issue feedback with format: ISSUE: "<quote>" | SIGN: <category> | FIX: <rewrite>. c. Save the feedback to a per-round file (e.g. ${P}_feedback_round${ROUND}.txt) so finalize can include it in the report. d. Extract count. If 0, break immediately (no rewrite needed). e. Call the AI agent (REWRITE_MODEL, e.g. opus) to rewrite. Write output directly to the text file, overwriting in place. CRITICAL: do NOT reference multiline env vars like WRITING_STYLE or ADDITIONAL_RULES directly in the script — Dagu expands them before the shell runs, which can break parsing. Read them from the helper files written by setup via cat instead. Only simple env vars (paths, model names, numbers) are safe to use directly. Step 4 — finalize: Build a full report with: metadata header (date, word counts, strictness, per-round issue counts), then an "Issues Found and Fixed" section listing all per-round feedback, then a "Final Text" section with the rewritten text. Clean up all helper files including per-round feedback files. Env var knobs (all top-level, easily customizable): - WRITING_STYLE: multiline (|) target writing style instructions - CHECK_STRICTNESS: low/medium/high - CHECK_MODEL: model for checking (cheaper, e.g. sonnet) - REWRITE_MODEL: model for rewriting (quality, e.g. opus) - ADDITIONAL_RULES: extra rules beyond the Wikipedia reference - WIKI_URL: Wikipedia raw URL (swappable) - WIKI_EXCERPT_LINES: how many lines of the wiki to feed the AI Use strongly typed params (name, type, description, default, minimum, maximum). Important: review the pitfalls reference for known workarounds. Follow the coding agent reference for the correct non-interactive command and model flags.

Getting Started

1. Install Dagu

curl -L https://raw.githubusercontent.com/dagu-org/dagu/main/scripts/installer.sh | bash

2. Install Dagu Skill

claude mcp add dagu -- dagu mcp

3. Start Dagu

dagu start-all

For more details, see the quickstart guide

Related Formulas