home / skills / sounder25 / google-antigravity-skills-library / 23_paste_sanitizer

23_paste_sanitizer skill

/23_paste_sanitizer

This skill converts chatty terminal output into safe, paste-ready command blocks by filtering prompts and outputs.

npx playbooks add skill sounder25/google-antigravity-skills-library --skill 23_paste_sanitizer

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.5 KB
---
name: Paste Sanitizer
description: Convert mixed terminal output and instructions into safe, paste-ready command blocks.
---

# SKILL-023: Paste Sanitizer

## Purpose

Convert “chatty” instructions, shell prompts, and terminal output into a safe, paste-ready command block that satisfies the **Pre-Action Guard (Skill-018)**.

This skill ensures that unintended text like `PS C:\`, `Everything up-to-date`, or error dumps are never pasted into a live terminal.

## Goal

Enforce **Command-Only** output for all runnable steps.

## Algorithm

1. **Identify** lines that match "likely command" patterns:
   - Starts with `git`, `dotnet`, `npm`, `python`, `cd`, `mkdir`, `$env:`, etc.
2. **Identify** and **Drop** lines that match "likely output" or "prompt" patterns:
   - Starts with `PS`, Contains `Everything up-to-date`, `At line:`, `CategoryInfo:`, `error:`, `warning:`, etc.
3. **Comment Out** (optional) unknown lines with `#` instead of deleting, to preserve context safely within a script.
4. **Wrap** the cleaned commands in a labeled block: `## COPY/PASTE COMMANDS`.

## Trigger Phrases

- `sanitize commands`
- `clean terminal output`
- `make paste-ready`

## Expected Output Format

```markdown
## COPY/PASTE COMMANDS
```powershell
git add .
git commit -m "fix"
git push
```

```

## Safety Constraints
- Only copy blocks labeled **COPY/PASTE COMMANDS**.
- Never copy blocks labeled **Expected Output**.
- If a line inside the command block does not start with a tool or verb, the sanitizer has failed.

## Implementation
See `scripts/paste_sanitizer.ps1`.

Overview

This skill converts mixed terminal transcripts, prompts, and explanatory chat into a safe, paste-ready PowerShell command block. It enforces a command-only output format so nothing accidental (prompts, outputs, or error dumps) is pasted into a live shell. The result is a labeled, minimal block ready for copy/paste under the Pre-Action Guard safety model.

How this skill works

The sanitizer scans input lines and classifies them as commands, prompts/output, or unknown context. Lines that match common command patterns (git, dotnet, npm, python, cd, mkdir, $env:, etc.) are retained; lines matching prompt or output patterns (PS C:\, Everything up-to-date, CategoryInfo:, error:, warning:, At line:) are dropped. Unknown lines are optionally commented out with # to preserve context safely, and the final cleaned commands are wrapped in a ## COPY/PASTE COMMANDS block labeled as PowerShell.

When to use it

  • When pasting mixed terminal logs into documentation or chat to produce runnable steps.
  • Before sharing commands from pair-programming sessions or support transcripts.
  • When extracting runnable steps from instructional text that includes prompts and outputs.
  • As a pre-step in automation pipelines that assemble shell scripts from human notes.

Best practices

  • Prefer explicit command prefixes (git, dotnet, npm, python, cd, mkdir, $env:) to improve detection accuracy.
  • Keep explanatory lines separate from command sections to avoid accidental inclusion.
  • Review commented-out lines (#) for any needed context before executing the block.
  • Always run the sanitized commands in a safe environment (dry-run, staging) when possible.

Example use cases

  • Convert a chat transcript with PS C:\ prompts and success messages into a clean git commit/push block.
  • Sanitize a support session that shows error dumps and commands so only the commands are copied.
  • Extract setup steps from an install guide that mixes commands with package manager output.
  • Prepare a minimal PowerShell script from a verbose console log for CI pipeline use.

FAQ

Will the sanitizer ever remove real commands by mistake?

It targets common prompt/output patterns first; ambiguous lines are commented out rather than deleted to avoid losing commands.

Can it handle non-PowerShell shells?

Patterns focus on PowerShell and common tools, but the approach supports extension to other shells by adding detection rules for their prompts and verbs.