# Send Documentation-Accurate Code Generation to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "doc-accurate-codegen",
    "name": "Documentation-Accurate Code Generation",
    "source": "tencent",
    "type": "skill",
    "category": "效率提升",
    "sourceUrl": "https://clawhub.ai/tobisamaa/doc-accurate-codegen",
    "canonicalUrl": "https://clawhub.ai/tobisamaa/doc-accurate-codegen",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/doc-accurate-codegen",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=doc-accurate-codegen",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "SKILL.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "doc-accurate-codegen",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-29T18:47:32.704Z",
      "expiresAt": "2026-05-06T18:47:32.704Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=doc-accurate-codegen",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=doc-accurate-codegen",
        "contentDisposition": "attachment; filename=\"doc-accurate-codegen-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "doc-accurate-codegen"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/doc-accurate-codegen"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/doc-accurate-codegen",
    "downloadUrl": "https://openagent3.xyz/downloads/doc-accurate-codegen",
    "agentUrl": "https://openagent3.xyz/skills/doc-accurate-codegen/agent",
    "manifestUrl": "https://openagent3.xyz/skills/doc-accurate-codegen/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/doc-accurate-codegen/agent.md"
  }
}
```
## Documentation

### Documentation-Accurate Code Generation

CRITICAL: This skill prevents LLM hallucination by enforcing documentation reference.

### When to Use

ALWAYS when generating code
ALWAYS when using APIs
ALWAYS when creating configurations
ALWAYS when implementing features

### Core Philosophy

NEVER generate code from memory. ALWAYS reference documentation.

### The Problem

LLMs hallucinate APIs that don't exist
Methods get renamed or removed
Parameters change or get deprecated
Return types shift unexpectedly
Configuration formats evolve

### The Solution

Load documentation FIRST — Before writing any code
Extract API signatures — Get actual method signatures
Generate from docs — Use real API data
Validate against docs — Check generated code matches
Reference tracking — Document which docs were used

### Workflow

1. IDENTIFY → What code/API/tool is needed?
2. LOCATE → Find documentation source
3. LOAD → Fetch and parse documentation
4. EXTRACT → Pull API signatures, parameters, examples
5. GENERATE → Create code using actual docs
6. VALIDATE → Check code matches documentation
7. REFERENCE → Track what docs were used

### 1. OpenClaw Internal Docs

Location: C:\\Users\\clipp\\AppData\\Roaming\\npm\\node_modules\\openclaw\\docs
Access: read tool
Use: For OpenClaw-specific APIs, tools, skills

### 2. Tool Documentation

Tool help: --help flags
Man pages: man <command>
Official docs: Use web_fetch to get docs

### 3. API Documentation

Official docs: Use web_fetch
OpenAPI specs: Parse and reference
Package docs: npm, pip, cargo docs

### 4. Code Examples

Existing code: Read similar implementations
Tests: Check test files for usage patterns
Examples: Find working code samples

### Step 1: Documentation Discovery

# For OpenClaw tools
read("openclaw-docs-path/tool-name.md")

# For external tools
web_fetch("https://docs.tool.com/api")

# For local tools
exec("tool --help")

### Step 2: API Signature Extraction

# Extract:
- Method names
- Parameters (names, types, required/optional)
- Return types
- Error handling
- Examples
- Version information

### Step 3: Code Generation

# Generate code using actual API data
def generate_from_docs(api_docs):
    # Use real method names
    # Use real parameter names
    # Use real return types
    # Include error handling from docs
    # Add docstrings from docs
    pass

### Step 4: Validation

def validate_against_docs(code, api_docs):
    # Check method names match
    # Check parameter names match
    # Check types match
    # Check return types match
    # Verify no hallucinated methods
    pass

### Quick Actions

codegen <api> — Generate code with doc reference
validate <code> — Check code against docs
doc-lookup <api> — Load and display documentation
api-extract <tool> — Extract API signatures

### Usage Examples

"Generate code to use the OpenClaw sessions_spawn tool"
# Process: Load docs → Extract API → Generate → Validate

"Create a Python script using the requests library"
# Process: Fetch requests docs → Extract API → Generate → Validate

"Write configuration for OpenClaw channels"
# Process: Load config docs → Extract format → Generate → Validate

### 1. Method Name Validation

Check method exists in docs
Verify spelling matches exactly
Confirm method is not deprecated

### 2. Parameter Validation

All required parameters present
Parameter names match docs exactly
Parameter types match docs
Optional parameters marked correctly

### 3. Return Type Validation

Return type matches docs
Error types match docs
Edge cases handled

### 4. Configuration Validation

Keys match documentation
Value types match schema
Required fields present
Format matches specification

### Common Hallucination Patterns

Non-existent methods — Methods that don't exist
Wrong parameter names — Hallucinated parameter names
Wrong types — Incorrect parameter/return types
Missing error handling — Ignoring documented errors
Wrong configuration format — Incorrect config structure

### Prevention Strategies

Always load docs first — Never generate from memory
Extract actual signatures — Don't guess API shape
Validate everything — Check against real docs
Reference tracking — Know which docs were used
Test with real APIs — Verify code actually works

### With Other Skills

Coding skill: Use this for doc-accurate code
Self-evolution: Update skills with doc validation
Content generation: Generate accurate code examples
Research: Research APIs from actual docs

### With OpenClaw Tools

read: Load internal documentation
web_fetch: Fetch external documentation
exec: Run tools with --help for docs
edit/write: Create validated code

### Format

# Code Generation Reference

## Generated Code
- File: path/to/file.py
- Generated: 2026-02-23
- Tool: doc-accurate-codegen

## Documentation Sources
1. OpenClaw Tool Docs: /docs/tools/exec.md
2. API Reference: https://docs.example.com/api
3. Examples: /examples/exec-usage.py

## Validation
- ✅ Method names validated
- ✅ Parameters validated
- ✅ Return types validated
- ✅ Error handling validated

## Notes
- Using exec tool with sandbox mode
- All parameters from official docs
- Error handling from API reference

### Output Template

When generating code, always include:

# Code generated with documentation reference
# Source: [documentation URL or path]
# Validated: [timestamp]
# API Version: [version if available]

def function_name():
    """
    [Docstring from actual documentation]
    
    Source: [link to docs]
    Parameters: [from docs]
    Returns: [from docs]
    """
    # Implementation using actual API
    pass

### Best Practices

Docs First, Always — Never generate without loading docs
Exact Matches — Use exact names, types, formats from docs
Validate Everything — Check all generated code
Track References — Document which docs were used
Test Real APIs — Actually run the code to verify
Update Regularly — Re-check docs as APIs evolve
Error Handling — Include all documented errors
Examples — Reference working examples from docs

### Common Pitfalls

Assuming API stability — APIs change, always re-check docs
Memory over docs — Trust docs, not memory
Partial loading — Load complete documentation
No validation — Always validate generated code
Missing references — Always track doc sources

### Success Metrics

Hallucination rate: 0% (all code references actual docs)
Validation rate: 100% (all code validated)
Reference tracking: 100% (all code has doc sources)
Error rate: 0% (no API misuse)
Test pass rate: 100% (all generated code works)

### 1. Automatic Doc Loading

Detect what APIs are needed
Automatically fetch relevant docs
Cache for future use

### 2. API Change Detection

Monitor docs for changes
Alert when APIs change
Suggest code updates

### 3. Multi-Source Validation

Cross-reference multiple doc sources
Detect conflicts between sources
Use most authoritative source

### 4. Example Extraction

Extract working examples from docs
Adapt examples to specific needs
Test examples before using

### Tool Documentation

# Get tool help
exec("tool --help")

# Read tool docs
read("openclaw/docs/tools/tool-name.md")

# Check tool examples
read("openclaw/examples/tool-usage.md")

### Skill Documentation

# Read skill docs
read("skills/skill-name/SKILL.md")

# Check skill examples
read("skills/skill-name/examples/")

### Configuration Documentation

# Read config docs
read("openclaw/docs/configuration.md")

# Check config examples
read("openclaw/examples/config/")

Remember: This skill exists because LLMs hallucinate. ALWAYS use it for code generation. The only way to prevent bugs is to reference actual documentation.
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: tobisamaa
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-04-29T18:47:32.704Z
- Expires at: 2026-05-06T18:47:32.704Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/doc-accurate-codegen)
- [Send to Agent page](https://openagent3.xyz/skills/doc-accurate-codegen/agent)
- [JSON manifest](https://openagent3.xyz/skills/doc-accurate-codegen/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/doc-accurate-codegen/agent.md)
- [Download page](https://openagent3.xyz/downloads/doc-accurate-codegen)