AI Agent Hub
Back to skills
Smart Legal Assistant icon

Smart Legal Assistant

Professional Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Please follow https://skillhub.cn/install/skillhub.md to install @user_5b1bdbdf/legal-hybrid-skill.

About this skill

The Problem: Unreliable Official Legal Data Sources

When handling labor disputes, loan issues, or consumer rights cases, obtaining accurate legal provisions and precedents quickly is essential. However, official channels like the National Legal Database API aren't always reliable—the API may timeout, return empty results, or become unavailable due to network fluctuations. For tools or applications dependent on legal information, this instability is critical. Hardcoding local provisions lacks comprehensive coverage and incurs high maintenance costs.

Dual-Layer Architecture: API-First with Local Fallback

Smart Legal Assistant addresses this with a hybrid query strategy:

  1. Official API Priority: Requests https://flk.npc.gov.cn/api/ with parameters type: flfg and keyword for fuzzy matching, returning 5 results by default. This ensures data authority.
  2. Automatic Degradation: When the API returns error status codes, times out (default 8 seconds), or yields no results, the system seamlessly switches to local databases.
  3. Local Data Support:
    • law_db.json: Pre-loaded with common provisions from Civil Code, Labor Contract Law, etc., structured as {"provision_name": "full_content"}.
    • case_db.json: Contains labor dispute, tort, and other cases with multi-dimensional matching via keywords array, fact, judgement, etc.
  4. Structured Output: Results are divided into "📜 Legal Provisions" and "⚖️ Reference Cases". Provisions prioritize API-sourced official content (falling back to local when unavailable); cases always come from the local library, sorted by relevance.

Usage Scenarios and Customization Notes

Typical query keywords include:
- Labor: 试用期辞退, 未签劳动合同, 工伤
- Loans: 借钱不还, 砍头息
- Contracts: 定金不退, 格式条款无效

Key considerations:
- File Completeness: main.py, law_db.json, case_db.json, and info.json are all mandatory.
- Case Library Accuracy: Match quality depends directly on keyword accuracy in case_db.json—continuously optimize based on actual query logs.
- API Timeout Adjustment: For slow networks, modify self.timeout parameter in main.py.
- Data Freshness: Local libraries require manual updates; API queries retrieve the latest provisions.

Use Cases

  • When handling employee probation termination disputes, need to query specific Labor Contract Law provisions and reference similar case judgments
  • Encountering a borrower delaying repayment without formal IOU, need to find civil lending regulations and precedents as collection basis
  • Resident injured by high-altitude falling objects needs to confirm tort liability provisions and understand compensation standards in similar cases
  • E-commerce seller disputing consumer claims for expired products, need to quickly retrieve Consumer Rights Protection Law provisions

Best For

  • SME HR managers: Need to confirm statutory calculation standards for severance pay before employee exit negotiations
  • Freelancers: Want to understand litigation process and evidence requirements when clients delay project payments
  • Community workers: Need to query legal definitions of noise disturbance when helping residents coordinate neighborhood disputes
  • Online store operators: Need to verify scope of seven-day no-reason return policy when handling customer complaints