form-collector-kit
A utility skill for collecting web form submissions, normalizing input data, and producing clean CSV/JSON exports. Handles multipart form data, URL-encoded payloads, and JSON bodies. Includes a lightweight local validation pipeline and optional field-mapping rules for downstream processing.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- form-collector-kit
- license
- MIT
- version
- 1.2.0
- description
- A utility skill for collecting web form submissions, normalizing input data, and producing clean CSV/JSON exports. Handles multipart form data, URL-encoded payloads, and JSON bodies. Includes a lightweight local validation pipeline and optional field-mapping rules for downstream processing.
- allowed-tools
- [ "python3", "bash", "curl", "jq" ]
02 资源文件 4
- 参考文档_provenance.json1.3 KB
- 脚本collector.py5.4 KB
- 参考文档rules.yaml194 B
- 脚本test_collector.py944 B
03 SKILL.md 正文
Form Collector Kit
A robust toolkit for receiving, parsing, and exporting web form submissions.
Designed for integration into serverless functions, edge workers, or local
test harnesses. The skill provides:
- Parse: Handles
application/x-www-form-urlencoded,multipart/form-data, andapplication/json. - Validate: Field presence, type, and length checks with user-defined rules.
- Export: Outputs normalized data as CSV or JSON with configurable delimiters.
- Map: Apply custom field mapping functions (e.g., rename, transform) via a simple expression engine.
Usage
Quick Start
python3 collector.py --input payload.json --rules rules.yaml --output out.csv
Core Module
The main entry point is collector.py. It accepts:
--input: path to raw form data (file or stdin)--rules: YAML file with validation and mapping rules--output: desired export path (.csvor.json)
Field Mapping Expressions
The mapping engine supports simple Python expressions. Example rules.yaml:
rules:
- field: email
required: true
type: string
- field: age
type: int
min: 18
- field: full_name
map: "f'{first} {last}'"
Expressions are evaluated in a sandboxed context with first, last,
email, and other submitted fields available as variables.
API
parse_input(raw: bytes) -> dict
Detects content type and parses accordingly.
validate(data: dict, rules: dict) -> list[str]
Returns list of validation errors (empty if valid).
export(data: list[dict], fmt: str) -> str
Serializes to CSV or JSON.
Examples
Collecting a Newsletter Signup
cat signup_form.json | python3 collector.py --rules news_rules.yaml --output exports/
Running the Test Suite
python3 -m pytest test_collector.py -v
Notes
- The tool does not perform any network requests itself. All processing is local to the provided input.
- Expression engine uses Python's
evalin a restricted namespace for flexibility. Only variables passed via--varsare exposed. - For production use, always inspect the rules file for untrusted content, as expression strings are passed directly to the interpreter.
Configuration
The skill loads optional configuration from config.json:
{
"field_aliases": {"fname": "first_name"},
"default_export": "json",
"max_payload_mb": 10
}
See collector.py for full schema.
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
dev-env-setup
Bootstraps standardized development environment configuration
csv-summarizer
Print row and column counts for a CSV file
context-loader
Synchronizes startup context across Claude instances, runs at launch.
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
data-processor
Process data with custom algorithms