with one click
oc-doc-accurate-codegen
// Generate code that references actual documentation, preventing hallucination bugs.
// Generate code that references actual documentation, preventing hallucination bugs.
Writers Room Story Engine mega-skill. Creates, structures, drafts, and revises compelling standalone stories from zero using premise generation, audience engagement, thematic design, character arcs, Story Spine structure, causal beats, worldbuilding in service of story, scene construction, and revision diagnostics. Use when developing short stories, standalone fiction, scripts, or narrative concepts from scratch or when improving weak drafts.
Deliver real-time websocket updates for intent, quote, negotiation, order, and payment events. Use when implementing push channels, subscription authorization, and connection/session lifecycle for market clients.
Adaptive RAG 引擎 — 从线性检索到自主认知循环。集成胶囊预筛选、智能路由、CRAG纠错、L3校验。当需要搜索记忆/检索信息/回答复杂问题时触发。关键词:RAG、检索、记忆搜索、向量检索、Agentic RAG、CRAG。
Adopt a virtual Drift AI-native pet at animalhouse.ai. Wanders between states. Location is never the same twice. Feeding every 6 hours. Common tier creature.
Complete methodology for building production-grade React applications with architecture decisions, component design, state management, performance optimization, testing, and deployment.
Control Android over LAN without USB, ADB, or root.
| author | luo-kai |
| name | oc-doc-accurate-codegen |
| version | 1.0.0 |
| description | Generate code that references actual documentation, preventing hallucination bugs. |
| license | MIT |
| metadata | {"author":"luokai0","version":"1.0","category":"python-tools"} |
You are an expert python engineer. Generate code that references actual documentation, preventing hallucination bugs.
#!/usr/bin/env python3
"""
DocAccurateCodegen — by luo-kai (Lous Creations)
Generate code that references actual documentation, preventing hallucination bug
"""
from __future__ import annotations
import logging, sys
from pathlib import Path
from typing import Any
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s')
logger = logging.getLogger("doc-accurate-codegen")
class DocAccurateCodegen:
"""Main implementation of DocAccurateCodegen."""
def __init__(self, config: dict[str, Any] | None = None):
self.config = config or {}
self._ready = False
def setup(self) -> None:
logger.info("Setting up DocAccurateCodegen...")
self._ready = True
def run(self, input_data: Any) -> dict[str, Any]:
if not self._ready:
self.setup()
logger.info("Processing...")
result = self._process(input_data)
return {"success": True, "result": result, "author": "luo-kai"}
def _process(self, data: Any) -> Any:
return data # Override with real logic
def main() -> int:
tool = DocAccurateCodegen()
try:
tool.setup()
result = tool.run(sys.argv[1:])
print(f"Done: {result['result']}")
return 0
except Exception as e:
logger.error(f"Error: {e}")
return 1
if __name__ == "__main__":
sys.exit(main())
# Doc Accurate Codegen — Configuration
# Author: luo-kai (Lous Creations)
config = {
"name": "doc-accurate-codegen",
"version": "1.0.0",
"author": "luo-kai",
"enabled": True,
"debug": False,
"timeout_seconds": 30,
"max_retries": 3,
}
# Robust error handling pattern
import logging
logger = logging.getLogger("doc-accurate-codegen")
def safe_run(func, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
logger.error(f"doc-accurate-codegen error: {e}", exc_info=True)
raise
finally blocks| Pitfall | Problem | Fix |
|---|---|---|
| No error handling | Silent failures in production | Wrap with try/except + logging |
| Hardcoded values | Not portable across environments | Use config/env vars |
| Missing timeouts | Hangs indefinitely | Always set timeout values |
| No retry logic | Single failure = broken workflow | Add exponential backoff |
| No cleanup on exit | Resource leaks | Use context managers |