Script writing

From event4u-app/agent-config · View interactive version

Script writing is an AI agent skill from the GitHub repository event4u-app/agent-config. Use when adding or editing any script under `scripts/` — `--quiet`, `_lib/script_output`, silent Taskfile wiring, Iron-Law carve-outs; fires on 'add a check script for X'.

How to use this skill

Skill file

<!-- cloud_safe: degrade -->

script-writing

When to use

Do NOT use this skill when:

Script vs other writers — critical test

| Intent | Artifact |

|---|---|

| "Maintenance script the agent or CI runs" | This skill |

| "User types /foo to invoke" | command-writing |

| "Constraint the agent must always honor" | rule-writing |

| "Reference knowledge agents cite" | guideline-writing |

Scripts orchestrate file checks, generators, and validators. They are

neither user-invoked nor agent-routed — task and CI call them.

Procedure

0. Run the Drafting Protocol

Creating or materially rewriting a script that joins the linter / check

family must go through Understand → Research → Draft from the

CODE0 rule.

check catches? Is it a one-off (then archive it) or evergreen?

overlap, skim 1–2 peer scripts (e.g. lint_handoffs.ts,

check_md_language.ts).

after the shape is confirmed.

1. `--quiet` flag — argv check

Every check_*.ts / lint_*.ts script MUST accept --quiet so the

silent Taskfile layer (§ 4) can suppress success-only output.

Canonical pattern (see e.g. lint_handoffs.ts):

const QUIET = process.argv.slice(2).includes('--quiet');
// ...
if (!QUIET) {
    console.log('✅ All clean');
}

Failure output (❌, non-zero exit) is never gated — failures must

always print regardless of --quiet.

2. `_lib/script_output` helpers — preferred for new scripts

For anything richer than a single ✅/❌, import the verbosity-aware

router instead of raw print():

import { info, success, warn, error, flush_summary } from './_lib/script_output.js';

info('Loading manifest');          // drops on silent + minimal
success('Wrote 3 files');          // collected at minimal, printed at verbose
warn('Skipping stale entry');      // stderr unless silent
error('Manifest missing');         // stderr always

flush_summary('Done — 3 entries'); // one-line summary at minimal

Resolution order (first wins, cached for the process):

  1. AGENT_SCRIPT_VERBOSITY env (silent / minimal / verbose)
  2. SCRIPT_OUTPUT_VERBOSE=1 alias (== verbose)
  3. .agent-settings.yml → verbosity.script_output
  4. Default minimal

The resolved level is exported back into AGENT_SCRIPT_VERBOSITY so

child processes inherit it. Tests reset via reset_level() from the

same module — see tests/lib/script_output.test.ts.

3. Iron-Law carve-outs — never silenced

The following surfaces MUST use plain print() and never the

helpers, so verbosity settings cannot suppress them:

setup-evals, install-hooks interactive sections

CODE0 — Hard Floor cannot be silenced

If unsure, check src/scripts/ai_council/one_off_archive/2026-05/README.md

for the archived carve-out inventory.

4. Taskfile wiring — `silent: true` + `{{.QUIET_FLAG}}`

Every Taskfile task that wraps a --quiet-aware script MUST set

silent: true and pass {{.QUIET_FLAG}} to the script:

# Per-task in taskfiles/*.yml:
tasks:
  lint-handoffs:
    silent: true
    cmd: ./scripts-run src/scripts/lint_handoffs {{.QUIET_FLAG}}

The QUIET_FLAG var is defined once at the root of Taskfile.yml

and resolves to "" only when AGENT_SCRIPT_VERBOSITY=verbose:

# Root Taskfile.yml — already in place, do not duplicate:
vars:
  QUIET_FLAG:
    sh: '[ "$AGENT_SCRIPT_VERBOSITY" = "verbose" ] && echo "" || echo "--quiet"'

Carve-out tasks (release, install secrets, CI orchestration — see § 3)

do not add silent: true and do not use {{.QUIET_FLAG}}.

5. Validate

Output format

  1. Script file at src/scripts/{name}.ts with --quiet accepted
  2. Taskfile wiring with silent: true + {{.QUIET_FLAG}} (unless carve-out)
  3. Test under tests/ if _lib/script_output is used
  4. Linter output showing 0 FAIL

Gotchas

Frugality Standards

Apply the Frugality Charter

to every script you author. Phase 10 of the charter (settings hooks

row — verbosity.script_output / verbosity.taskfile_command_echo)

is what this skill exists to teach.

Examples in this artifact:

--quiet so the only thing visible at minimal is the end-of-run

summary or a failure.

output collect via success() and emit one flush_summary() line.

a Hard Floor surface (§ 3 carve-outs).

Pre-save self-check:

  1. Does every print("✅ ...") line sit behind --quiet / the helper?
  2. Does the script add silent: true + {{.QUIET_FLAG}} to its

Taskfile entry (unless a carve-out)?

  1. Are failure lines (❌, exit non-zero) never gated by quiet?
  2. Are Iron-Law surfaces using plain print() and not the helper?

Do NOT

Cloud Behavior

On cloud surfaces (Claude.ai Web, Skills API) the package's task

runner and _lib/script_output are not reachable. The skill still

applies — with prose-only validation:

Examples

Good description (trigger-shaped, names domain + symptoms):

"Use when adding or editing any script under scripts/ — --quiet flag, _lib/script_output helpers, silent Taskfile wiring, Iron-Law carve-outs — even when you just say 'add a check script for X'."

Bad description (vague, no trigger):

"Script conventions"

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.