Skip to main content
ClaudeWave
ES, Spanish
Skill288 estrellas del repoactualizado 7d ago

codex-log-guard

Diagnose excessive Codex local SQLite diagnostic log writes with read-only evidence by default. Use when a user mentions logs_2.sqlite, logs_2.sqlite-wal, block_log_inserts, SSD/TBW wear, or explicitly asks to protect, clean up, verify, or restore Codex diagnostic logging.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/majiayu000/spellbook /tmp/codex-log-guard && cp -r /tmp/codex-log-guard/skills/codex-log-guard ~/.claude/skills/codex-log-guard
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Codex Log Guard

## Overview

Diagnose Codex persistent diagnostic logging from local evidence, then give a concise conclusion and the safest next action. Do not make the user choose from a command menu.

## Operating Contract

Select one mode from the current user request:

- `diagnose_only` is the default for check, inspect, explain, or verify requests. It is read-only.
- `protect` requires an explicit request to stop or mitigate log writes. It may install and verify `block_log_inserts`, but it does not delete rows or vacuum files.
- `cleanup` requires an explicit current request to reclaim disk space or clean up logs. It first installs protection when needed, creates and verifies a timestamped backup, and only then deletes log rows and vacuums.
- `restore` requires an explicit request to resume diagnostic logging. It may drop only the known `block_log_inserts` trigger.

Generic wording such as "处理", "修一下", or "止血" selects `protect`, not `cleanup`. Prior approval does not carry into a later run. If the requested write mode is ambiguous, return the `diagnose_only` report and the exact proposed mutation without applying it.

Direct actions:

- Run local read-only file, SQLite schema, row, and open-process checks.
- Apply only the mutation authorized by the selected mode and verify its result.

Escalate before:

- Touching any database outside the two declared Codex log paths, deleting a backup, killing a process, or changing remote telemetry or credentials.

Evidence-backed pushback:

- Reject cleanup when protection is unverified, the backup check failed, or sampled row IDs still move. Cite the exact database path and failed command instead of treating file size as proof.

Feedback loop:

- When a new schema, active path, or false-success signal is confirmed more than once, update this Skill's diagnosis rules and a focused contract test before automating that case.

`agents/openai.yaml` contains discovery UI metadata only; it is not an operational instruction source.

## Default Flow

When the user asks to "check", "看看", "诊断", or asks whether the local machine is affected:

1. Inspect all candidate live database files and schemas:
   - `~/.codex/logs_2.sqlite`
   - `~/.codex/sqlite/logs_2.sqlite`
2. Identify which candidate database is currently held by Codex processes.
3. Check whether `block_log_inserts` already exists on each candidate with a `logs` table.
4. Measure whether `logs` is still being written using `COUNT(*), MIN(id), MAX(id)` samples.
   Treat `MAX(id)` or `MIN(id)` movement with stable `COUNT(*)` as active churn, not necessarily disk growth.
4. Inspect low-level log volume with `TRACE`/`DEBUG` counts and top noisy targets.
5. Check which Codex processes currently hold each candidate database.
6. Return a diagnosis with:
   - current state: healthy / protected / affected historically / actively writing / actively growing on disk / missing database / blocked
   - evidence: file sizes, trigger state, row/min-id/max-id samples, level distribution, active path
   - recommended next action: do nothing / install trigger / cleanup later / cleanup now / restore logging
7. Do not ask the user which command to run. Choose the diagnosis path from the evidence.

In `protect` mode:

1. Install `block_log_inserts` first.
2. Verify that `COUNT(*), MAX(id)` stops growing.
3. Report the protected database path and fresh samples. Do not delete or vacuum rows.

In `cleanup` mode:

1. Complete and verify protection first.
2. Create a timestamped SQLite `.backup` and require a non-empty file plus a successful `PRAGMA quick_check` result.
3. Delete log rows, vacuum, and checkpoint the WAL.
4. Report the backup path and final file sizes.

In `restore` mode:

1. Drop `block_log_inserts`.
2. Sample `COUNT(*), MAX(id)` to confirm logging resumes or stays quiet.

## Evidence Commands

Run direct shell/SQLite commands. Use only the needed subset for the user's request; do not paste a menu back to the user.

Inspect files:

```bash
for db in ~/.codex/logs_2.sqlite ~/.codex/sqlite/logs_2.sqlite; do
  ls -lh "$db"* 2>/dev/null
  du -h "$db"* 2>/dev/null
done
```

After `lsof` identifies the active candidate, validate the selected path in the
same shell command before running any later SQLite snippet:

```bash
: "${CODEX_LOG_DB:?set CODEX_LOG_DB to the verified active candidate}"
case "$CODEX_LOG_DB" in
  "$HOME/.codex/logs_2.sqlite"|"$HOME/.codex/sqlite/logs_2.sqlite") ;;
  *) echo "refusing unexpected Codex log database path" >&2; exit 2 ;;
esac
readonly db="$CODEX_LOG_DB"
```

Do not supply a default. If no active path can be proven, stay in
`diagnose_only` and report the ambiguity.

Check schema and trigger:

```bash
sqlite3 "$db" ".tables"
sqlite3 "$db" "PRAGMA table_info(logs);"
sqlite3 "$db" "SELECT name, tbl_name, sql FROM sqlite_master WHERE type='trigger' AND name='block_log_inserts';"
```

Sample writes and growth:

```bash
for i in 1 2 3; do
  date '+%F %T'
  sqlite3 "$db" "SELECT COUNT(*) AS rows, MIN(id) AS min_id, MAX(id) AS max_id FROM logs;"
  stat -f '%N %z bytes mtime=%Sm' "$db" "$db-wal" "$db-shm" 2>/dev/null
  sleep 10
done
```

Inspect levels and noisy targets:

```bash
sqlite3 "$db" "SELECT level, COUNT(*) AS n, ROUND(SUM(estimated_bytes)/1024.0/1024.0, 1) AS estimated_mib FROM logs GROUP BY level ORDER BY n DESC;"
sqlite3 "$db" "SELECT target, level, COUNT(*) AS n, ROUND(SUM(estimated_bytes)/1024.0/1024.0, 1) AS estimated_mib FROM logs GROUP BY target, level ORDER BY n DESC LIMIT 15;"
```

Check open processes:

```bash
lsof ~/.codex/logs_2.sqlite ~/.codex/logs_2.sqlite-wal ~/.codex/logs_2.sqlite-shm \
     ~/.codex/sqlite/logs_2.sqlite ~/.codex/sqlite/logs_2.sqlite-wal ~/.codex/sqlite/logs_2.sqlite-shm 2>/dev/null
```

Install protection:

```bash
sqlite3 "$db" "PRAGMA busy_timeout=10000; CREATE TRIGGER IF NOT EXISTS block_log_inserts BEFORE INSERT ON logs BEGIN SELECT RAISE(IGNORE); END;"
```

Clean up after protection:

```bash
backup="$db.bak.$(date +%Y%m%d-%H%M%S)"
sqlit
agentsmd-optimizeSkill

Audit AND optimize a CLAUDE.md / AGENTS.md instruction file — score it against the five high-leverage patterns, flag anti-patterns, then apply approved fixes in place. Use when the user says 优化 CLAUDE.md / 优化 AGENTS.md / optimize my agent doc / 帮我改 claudemd, or after an audit when they want the fixes applied (not just reported).

agentsmd-scaffoldSkill

Generate or update repository-specific AGENTS.md instruction files from real repo evidence. Use when asked to create, design, scaffold, split, or improve root or scoped AGENTS.md files for Codex/Claude/agent workflows, especially when a repo needs directory-specific rules, validation commands, generated-file boundaries, or a short agent onboarding router.

api-designSkill

REST/GraphQL/gRPC API design best practices. Use when designing APIs, defining contracts, handling versioning. Covers OpenAPI 3.2, GraphQL Federation, gRPC streaming.

app-ui-designSkill

Mobile app UI design expert for iOS and Android. Use when designing app interfaces, creating design systems, ensuring accessibility, or following platform guidelines. Covers Material Design 3, Human Interface Guidelines, color theory, typography, and 2025 trends.

app-user-story-qaSkill

End-to-end app feature inventory and user-story testing workflow with a canonical tracker. Use when the user asks to audit every feature, derive expected behavior from code, test user journeys, or explicitly fix and retest documented UX or logistical defects.

architecture-foundationSkill

Design architecture foundations before implementation. Use when asked to design or refactor architecture, choose Rust/Go crate, package, module, runtime, workflow, or service boundaries, compare mature project architecture, prevent stacked one-off PRs, audit migration debt in existing repos, or produce a spec before coding.

architecture-researchSkill

Evidence-driven architecture research for understanding real systems and making technical decisions. Use when doing architecture landscape studies, source-backed system archaeology, build-vs-buy or adopt/adapt/build decisions, open-source and commercial comparisons, revisiting an earlier architecture choice, or handling requests such as 架构调研, 架构选型, 竞品架构, 技术尽调, 同类方案, 开源替代, how is X built, and what should we learn from X. Do not use for small mechanical changes, market-only discovery, or detailed design after the technology direction is already fixed.

ask-opencliSkill

Ask Grok or Gemini via opencli (browser-session based, no API cost). Use when the user says "问 grok", "问 gemini", "ask grok", "ask gemini", "用 grok 查", "grok 怎么看", "让 gemini 分析", or wants a second opinion from Grok/Gemini without paying API tokens. Routes to opencli which drives the already-logged-in Chrome session.