Overview
Extract valuablelegal Q&A pairsfrom lawyer-client communication records (client questions + lawyer answers) to generate structured knowledge base content. Suitable for transforming client consultations into reusable legal knowledge for later organization into articles, cases, or learning materials.
Core Value: Extract Q&A content that can be reused by other clients, rather than the specific case details of a single client.
Core Principles
Client Information Protection
Absolutely prohibitedto include the following in Q&A content:
- ❌ Client's real name
- ❌ Enterprise/institution name
- ❌ Specific address, contact information
- ❌ Any information that can identify an individual or enterprise
Anonymization Standards:
- ✅ Client name → Use aliases such as "the party," "the client," "Party A/Party B," etc.
- ✅ Enterprise name → Use aliases such as "a certain company," "a certain enterprise," "the enterprise," etc.
- ✅ Specific information → Blur into "a certain place," "a certain time," "relevant personnel," etc.
- ✅ Client's original words → Quote after anonymization: "the client asked..." rather than "President Zhang said..."
Value Judgment of Q&A Pairs
Extracted Q&A should meet at least one of the following conditions:
- Universality: Other clients may also encounter the same type of issue
- Typicality: Represents common concerns in a certain type of legal scenario
- Educational Value: The lawyer's answer has legal popularization value or guiding significance
- Reusability: Can stand alone as an article or serve as a knowledge base entry
Workflow
Step 1: Analyze Input Content
Obtain the communication record document and the user's specific requirements, and understand:
- The communication content and context in the document
- Which aspects the user wants to focus on
- Which Q&A have reuse value
Step 2: Identify Valuable Q&A Pairs
Comprehensively review the Q&A content in the document, and identify value according to the following dimensions:
Q&A Identification Dimensions
- Direct Q&A - The client clearly raises a question, and the lawyer provides an answer
- Follow-up Response - The client asks a follow-up question, and the lawyer further explains
- Risk Reminder - Risk points proactively reminded by the lawyer and response suggestions
- Operational Guidance - Q&A involving processes, steps, and precautions
- Common Concerns - The same type of issue that other clients may also encounter
Q&A Extraction Methods
- Semantic Analysis: Understand the client's true question and the lawyer's core viewpoint
- Logical Summarization: Organize scattered dialogue into independent Q&A pairs
- Value Assessment: Determine whether the Q&A has universal applicability
- Standardized Expression: Convert colloquial expressions into standardized question-and-answer format
Step 3: Generate structured report
Save the output file tothe same directory as the original document, file naming:{原文档名}_法律问答提取_{YYYYMMDD}.md
Output formatSee details in output-template.md。
Each question-and-answer pair includes the following parts:
- Question: the question raised by the client (standardized wording)
- Lawyer's answer: the lawyer's core viewpoints and suggestions (300-500 words)
- Question background(optional): the context in which the question arose (200-300 words)
- Value labels: universality/typicality/educational value/reusability
- Applicable scenarios: under what circumstances readers would care about this question and answer
Step 4: Question-and-answer classification and association
Provide the following analysis dimensions:
- Question-and-answer feature analysis: number of key question-and-answer items, number of regular question-and-answer items, value distribution
- Domain classification: classify by legal domain or business scenario
- Association analysis: which question-and-answer items are related and can be combined into an article
Quality standards
- Independence: each question-and-answer pair can be understood independently, without relying on the full conversation context
- Universality: the question-and-answer content also has reference value for other clients
- Completeness: both the question and the answer are clear and complete, without being taken out of context
- Strict anonymization: strictly follow client information protection rules
- Reusability: the extracted question-and-answer items can be directly used in articles, knowledge bases, or learning materials
Input requirements
This skill accepts the following types of input:
- Document path: the path of the communication record document provided by the user
- Pasted content: communication record content pasted directly by the user
- User requirements: what types of question-and-answer items the user wants to focus on
Configuration and archiving
User configuration
This skill supports customizing scanning behavior through config/.env files:
# 复制模板
cp config/.env.example config/.env
# 编辑配置
QA_EXTRACTOR_SCAN_PATHS=~/Documents/legal-consultations
QA_EXTRACTOR_SCAN_DEPTH=3
QA_EXTRACTOR_FILE_TYPES=md,txt
Scan records
The skill maintains archive/scan-log.json to record scanning status:
{
"version": "1.1.0",
"last_full_scan": "2026-05-10T23:00:00+08:00",
"watch_paths": [
{
"path": "~/Documents/legal-consultations",
"last_scanned": "2026-05-10T23:00:00+08:00",
"status": "active"
}
],
"projects": {
"潜在项目_A": {
"source_files": ["path/to/file1.md", "path/to/file2.md"],
"last_extracted": "2026-05-10",
"qa_count": 8,
"output_file": "archive/extractions/2026-05-10_潜在项目_A_qa.md",
"status": "active"
}
},
"files": {
"path/to/file.md": {
"content_hash": "sha256:abc123...",
"last_modified": "2026-05-09",
"last_extracted": "2026-05-10",
"qa_count": 5,
"status": "active"
}
},
"archived": {
"path/to/old_project": {
"archived_at": "2026-05-01",
"reason": "moved_by_user"
}
}
}
Field descriptions:
| Field | Purpose |
|---|---|
files.*.content_hash |
File content fingerprint; when it changes, re-extraction is triggered |
files.*.status |
active / archived, skip scanning after archiving |
projects.*.source_files |
Multiple communication records for the same project, merged output |
projects.*.status |
active / archived, locked after the project is archived |
archived.* |
Record paths that have been moved away to prevent duplicate scanning |
Incremental scanning logic:
Folder type determination (used to identify archived and active projects):
| Naming pattern | Type | Processing method |
|---|---|---|
Pure numbers / date range (e.g., 24、25 01-06、26 01-06) |
Archive container | Deep scan internal subfolders |
Date + name (e.g., 260323 张美金...、260404 顾忆芬...) |
Direct project | Directly scan this folder |
| Other | Project | Directly scan this folder |
- Iterate over all direct subfolders under watch_paths
- Determine the type of each folder (archive container / direct project)
- Recursively scan archive containers; scan content files for direct projects
- Compute for each file
content_hash - If a file is not in scan-log, or its hash does not match the record → trigger extraction
- Trigger extraction only if all files in the project have changed
- After extraction is complete, merge multiple records by project and output a single QA file
Extraction result archiving
The extracted question-answer pairs are saved in archive/extractions/ directory, aggregated by project:
archive/
├── scan-log.json # 扫描状态记录
└── extractions/
├── 2026-05-10_潜在项目_A_qa.md # 项目A的多轮咨询合并
├── 2026-05-10_潜在项目_B_qa.md # 项目B的单次记录
└── 2026-05-11_潜在项目_C_qa.md # 项目C(后续增量新增)
Multi-round consultation merge logic:
- All
.md/.txtfiles within the same project folder are treated as multiple rounds of communication for the same project - During extraction, integrate all question-answer pairs in file order (filename or modification time)
- Deduplication: for multiple occurrences of the same question, keep the latest answer
- Output filename:
{日期}_{项目名}_qa.md
Note:archive/ The directory is not included in Git version control.
Applicable scenarios
- Organize customer consultation records into reusable knowledge
- Extract content marketing material from conversations
- Build a legal question-and-answer knowledge base
- Prepare material for legal popularization articles
- Create a list of frequently asked customer questions
- Regularly scan project folders and incrementally extract new content