一键导入
extract
Extract structured information (email, url, date, entity) from unstructured text with schema + anti-hallucination guardrails.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Extract structured information (email, url, date, entity) from unstructured text with schema + anti-hallucination guardrails.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | extract |
| description | Extract structured information (email, url, date, entity) from unstructured text with schema + anti-hallucination guardrails. |
| license | MIT OR Apache-2.0 |
| compatibility | Native (CLI, llama.cpp), Browser (WebLLM), Edge (Deno HTTP LLM) |
| metadata | {"targets":["email","url","date","entity","name"],"version":"1.0.0","guardrails":["json-schema","anti-hallucination"]} |
| allowed-tools |
extract
Extract structured information from unstructured text or content. This skill transforms free-form text into validated, structured JSON output.
Supported extraction targets:
email - Email addressesurl - URLs and web linksdate - Dates in various formatsentity - Named entities (people, organizations, locations)name - Person names (first name, last name, full name)The agent MUST invoke this skill when:
The agent MUST NOT invoke this skill when:
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The unstructured text to extract from |
target | string | Yes | What to extract: email, url, date, entity, or name |
text must be non-emptytext must be at least 1 charactertarget must be one of the supported typesOutput is always JSON with the following structure:
{
"<target>": <extracted_value>
}
| Target | Output Type | Example |
|---|---|---|
email | string or string[] | {"email": "hello@agent.rs"} |
url | string or string[] | {"url": "https://agent.rs"} |
date | string or string[] | {"date": "2024-01-15"} |
entity | object | {"entity": {"people": ["John"], "orgs": []}} |
name | string or string[] | {"name": ["John Smith", "Jane Doe"]} |
This skill fails explicitly in these cases:
| Failure | Cause | Agent Behavior |
|---|---|---|
InvalidTarget | Unknown extraction target | Fail immediately, do not retry |
EmptyInput | Empty text provided | Fail immediately |
NoMatch | No patterns found | Return empty array (not failure) |
MalformedOutput | LLM returned non-JSON | Guardrail rejects, agent may retry |
SchemaViolation | Output missing required fields | Guardrail rejects, agent may retry |
The Extraction skill enforces these guardrails:
REJECT if:
- Output is empty
- Output is not valid JSON
- Output missing target field
- Extracted value not found in source text
- Value format doesn't match target type
# Execution
agent extract --text "Contact: hello@agent.rs" --target "email"
# Success output (stdout)
{"email": "hello@agent.rs"}
# Failure output (stderr) + exit code 1
Error: InvalidTarget - unknown target 'phone'
// Execution
const result = await agent.invokeSkill('extract', {
text: 'Contact: hello@agent.rs',
target: 'email'
});
// Success
{ email: 'hello@agent.rs' }
// Failure - throws SkillError
SkillError: InvalidTarget - unknown target 'phone'
// HTTP Request
POST /skill/extract
Content-Type: application/json
{ "text": "Contact: hello@agent.rs", "target": "email" }
// Success Response (200)
{ "email": "hello@agent.rs" }
// Failure Response (400)
{ "error": "InvalidTarget", "message": "unknown target 'phone'" }
Input:
{
"text": "For support, email us at support@agent.rs or sales@agent.rs",
"target": "email"
}
Output:
{
"email": ["support@agent.rs", "sales@agent.rs"]
}
Input:
{
"text": "Visit https://agent.rs or check https://github.com/hwclass/agent.rs",
"target": "url"
}
Output:
{
"url": ["https://agent.rs", "https://github.com/hwclass/agent.rs"]
}
Input:
{
"text": "The meeting is scheduled for January 15, 2024 at 3pm",
"target": "date"
}
Output:
{
"date": "2024-01-15"
}
Input:
{
"text": "John Smith from Anthropic met with Sarah at Google headquarters",
"target": "entity"
}
Output:
{
"entity": {
"people": ["John Smith", "Sarah"],
"organizations": ["Anthropic", "Google"],
"locations": ["Google headquarters"]
}
}
Input:
{
"text": "The report was prepared by Dr. Jane Smith and reviewed by Michael Johnson.",
"target": "name"
}
Output:
{
"name": ["Dr. Jane Smith", "Michael Johnson"]
}
Input:
{
"text": "This text contains no email addresses",
"target": "email"
}
Output:
{
"email": []
}
Input:
{
"text": "Contact us anytime",
"target": "email"
}
Invalid LLM Output (REJECTED):
{
"email": "contact@example.com"
}
Rejection Reason: contact@example.com does not appear in source text - hallucination detected.
Contract Version: 1.0.0 Last Updated: 2024