Validate Inputs
Testing & Qualityvalidate-inputsValidate Inputs is an Agent Skill for testing & quality published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Check function inputs for correctness and safety. Use when implementing defensive programming.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/quality/validate-inputs-homericintelligence-projectodyssey-2/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/validate-inputs, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Validate Inputs
Implement input validation to ensure functions receive correct data types, shapes, ranges, and formats.
When to Use
- Adding defensive checks to functions
- Improving error messages for bad inputs
- Ensuring tensor shape/dtype correctness
- Validating configuration parameters
Quick Reference
# Input validation pattern
def validate_tensor(tensor):
assert tensor is not None, "Tensor cannot be None"
assert isinstance(tensor, ExTensor), "Must be ExTensor type"
assert len(tensor.shape) > 0, "Tensor shape cannot be empty"
assert tensor.dtype() in [DType.float32, DType.float64], "Invalid dtype"
return True
# Usage with context
try:
validate_tensor(input_data)
except AssertionError as e:
raise ValueError(f"Invalid input: {e}")
Workflow
- Document expectations: Specify types, shapes, ranges for inputs
- Implement checks: Add validation before processing
- Provide error messages: Clear messages for validation failures
- Test edge cases: Verify validation catches invalid inputs
- Document behavior: Note what validation is performed
Output Format
Input validation specification:
- Parameter name and type
- Constraints (shape, range, valid values)
- Error handling strategy
- Error messages returned
- Test cases for invalid inputs
References
- See
generate-testsskill for validation test cases - See CLAUDE.md > Defensive Programming for best practices
- See
scan-vulnerabilitiesskill for security validation