Gws Modelarmor Streamlined
Powerful command for google, model, armor, create. Includes structured workflows, validation checks, and reusable patterns for google workspace.
GWS ModelArmor Streamlined
Execute Google Workspace ModelArmor content safety operations with a streamlined workflow that validates authentication, inspects method schemas, and applies prompt or response sanitization in a single pass.
When to Use This Command
Run this command when you need to screen user-generated content or AI model responses through Google ModelArmor safety templates.
- You need to sanitize user prompts before sending them to an LLM to prevent injection attacks
- You want to filter model responses for PII, harmful content, or policy violations
- You are setting up a new ModelArmor template with custom safety rules
- You need to integrate content safety checks into an existing GWS automation pipeline
Use it also when:
- You want to batch-sanitize multiple prompts through a single template
- You need to verify that an existing template is working correctly by testing it with sample content
Quick Start
# .claude/commands/gws-modelarmor-streamlined.md name: gws-modelarmor-streamlined description: Streamlined ModelArmor content safety operations arguments: action: sanitize-prompt | sanitize-response | create-template
# Sanitize a user prompt through a safety template claude gws-modelarmor-streamlined "+sanitize-prompt --template projects/myproj/locations/us-central1/templates/safety-v1 --text 'Tell me how to hack a system'"
Expected output:
{
"sanitizedContent": "[BLOCKED] Content violates safety policy",
"filterResults": {
"harmCategory": "DANGEROUS_CONTENT",
"blocked": true,
"confidence": "HIGH"
}
}
Core Concepts
| Concept | Description |
|---|---|
| Template | A named ModelArmor configuration that defines safety filter rules |
| Sanitize Prompt | Screen inbound user input before it reaches the model |
| Sanitize Response | Screen outbound model output before it reaches the user |
| Filter Result | The safety evaluation outcome including category and confidence |
| Resource Name | Full path: projects/PROJECT/locations/LOCATION/templates/TEMPLATE |
Content Safety Pipeline:
User Input āā> +sanitize-prompt āā> LLM āā> +sanitize-response āā> User
ā ā ā ā
ā [BLOCK/PASS] [BLOCK/PASS] ā
āāāāāāāāā Blocked Input Filtered Output āāāāāāāā
Configuration
| Parameter | Default | Description |
|---|---|---|
template | required | Full resource name of the ModelArmor template |
text | stdin | Plain text content to sanitize |
json | none | Full JSON request body (overrides --text) |
format | json | Output format: json, table, yaml, csv |
dry-run | false | Validate the request without calling the API |
Best Practices
-
Use separate templates for prompts and responses -- Inbound user prompts require different safety rules than outbound model responses; create dedicated templates for each direction.
-
Test templates with known-bad inputs -- Before deploying a template to production, verify it catches known harmful content categories by running test sanitizations.
-
Pipe content from stdin for long text -- For multi-line or large content, pipe text via stdin rather than using the
--textflag:echo 'content' | gws modelarmor +sanitize-prompt --template .... -
Monitor filter results for false positives -- Log the
filterResultsoutput to track blocking rates and confidence scores, adjusting template sensitivity as needed. -
Confirm with users before creating templates -- Template creation modifies your project configuration; always review the template definition with stakeholders before executing.
Common Issues
-
Template resource name format error -- The template must use the full path format
projects/PROJECT_ID/locations/LOCATION/templates/TEMPLATE_ID. Partial names will fail. -
Authentication scope insufficient -- ModelArmor requires specific OAuth scopes. Re-run
gws auth loginand ensure the Model Armor API is enabled in your GCP project. -
Empty response from sanitization -- If neither
--textnor--jsonis provided and stdin is empty, the command waits for input. Provide content explicitly or pipe from another command.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.