openviking
Manage AI agent context (memory, resources, skills) using OpenViking's file system paradigm. Use when: building agents with persistent context, managing agent memories across sessions, implementing hierarchical context delivery for complex agent systems.
Best use case
openviking is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Manage AI agent context (memory, resources, skills) using OpenViking's file system paradigm. Use when: building agents with persistent context, managing agent memories across sessions, implementing hierarchical context delivery for complex agent systems.
Teams using openviking should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/openviking/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How openviking Compares
| Feature / Agent | openviking | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Manage AI agent context (memory, resources, skills) using OpenViking's file system paradigm. Use when: building agents with persistent context, managing agent memories across sessions, implementing hierarchical context delivery for complex agent systems.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# OpenViking
## Overview
Manage AI agent context using a file-system paradigm — context is organized as files and directories that agents can read, write, and navigate. Inspired by ByteDance's OpenViking, this approach treats context like a filesystem: hierarchical, scoped, persistent, and self-evolving. Agents don't just consume context — they organize and update it.
## Core Concepts
```
context/
├── project/
│ ├── README.md # Project overview (always loaded)
│ ├── architecture.md # System design context
│ └── decisions/ # Architecture decision records
├── task/
│ ├── current.md # Active task context
│ └── history/completed/ # Past task context for reference
├── memory/
│ ├── facts.md # Known facts about the project
│ ├── lessons.md # Lessons learned from mistakes
│ └── preferences.md # User preferences and patterns
└── skills/
├── coding-style.md # Code conventions
└── tools.md # Available tools and how to use them
```
**Key idea:** Context is not a flat prompt. It's a tree with scoping rules — agents see context relevant to their current scope, not everything at once.
## Instructions
When a user asks to build agent memory, persistent context, or hierarchical context systems:
1. **Design the context tree** — Map out what context exists and how it's organized
2. **Define scoping rules** — What context loads at each level (project, task, subtask)
3. **Implement CRUD** — Agents need to read, create, update, and delete context files
4. **Add self-evolution** — Agents update context based on outcomes and learnings
### Context Manager Implementation
```python
"""File-system based context manager for AI agents."""
import os, json
from pathlib import Path
from datetime import datetime, timezone
from typing import Optional
class ContextManager:
"""Manages hierarchical context for AI agents."""
def __init__(self, root: str = "./context"):
self.root = Path(root)
self.root.mkdir(parents=True, exist_ok=True)
def read(self, path: str) -> Optional[str]:
full = self.root / path
return full.read_text() if full.is_file() else None
def write(self, path: str, content: str, metadata: Optional[dict] = None):
full = self.root / path
full.parent.mkdir(parents=True, exist_ok=True)
header = ""
if metadata:
meta = {**metadata, "updated": datetime.now(timezone.utc).isoformat()}
header = f"<!-- meta: {json.dumps(meta)} -->\n\n"
full.write_text(header + content)
def list(self, path: str = "") -> list[str]:
full = self.root / path
if not full.is_dir():
return []
return [str(p.relative_to(self.root)) for p in sorted(full.rglob("*")) if p.is_file()]
def delete(self, path: str):
full = self.root / path
if full.is_file():
trash = self.root / ".trash" / path
trash.parent.mkdir(parents=True, exist_ok=True)
full.rename(trash)
def search(self, query: str, path: str = "") -> list[tuple[str, str]]:
results = []
for filepath in self.list(path):
content = self.read(filepath)
if content and query.lower() in content.lower():
idx = content.lower().index(query.lower())
snippet = content[max(0, idx - 50):idx + len(query) + 50]
results.append((filepath, snippet))
return results
```
### Hierarchical Context Delivery
```python
class ScopedContext:
"""Delivers context based on the agent's current scope."""
SCOPE_RULES = {
"project": ["project/README.md", "memory/facts.md", "memory/preferences.md", "skills/coding-style.md"],
"task": ["task/current.md"],
"subtask": [],
}
def __init__(self, ctx: ContextManager):
self.ctx = ctx
def get_context(self, scope: str = "task", subtask_id: Optional[str] = None) -> str:
parts = []
for path in self.SCOPE_RULES["project"]:
content = self.ctx.read(path)
if content:
parts.append(f"## {path}\n{content}")
if scope in ("task", "subtask"):
for path in self.SCOPE_RULES["task"]:
content = self.ctx.read(path)
if content:
parts.append(f"## {path}\n{content}")
if scope == "subtask" and subtask_id:
content = self.ctx.read(f"task/subtasks/{subtask_id}.md")
if content:
parts.append(f"## Subtask: {subtask_id}\n{content}")
lessons = self.ctx.read("memory/lessons.md")
if lessons:
parts.append(f"## Lessons Learned\n{lessons}")
return "\n\n---\n\n".join(parts)
```
### Self-Evolving Context
Agents don't just read context — they update it based on what they learn:
```python
class EvolvingAgent:
def __init__(self, ctx: ContextManager, llm):
self.ctx = ctx
self.llm = llm
async def complete_task(self, task: str, result: str, success: bool):
timestamp = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M")
current = self.ctx.read("task/current.md")
if current:
self.ctx.write(f"task/history/{timestamp}.md", current)
if not success:
lesson = await self.llm.invoke(
f"Task: {task}\nResult: {result}\n\nWhat went wrong? Extract a concise lesson."
)
existing = self.ctx.read("memory/lessons.md") or ""
self.ctx.write("memory/lessons.md", f"{existing}\n\n### {timestamp}\n{lesson.content}")
new_facts = await self.llm.invoke(
f"Task: {task}\nResult: {result}\n\nAny new facts discovered? List them or say NONE."
)
if "NONE" not in new_facts.content:
existing = self.ctx.read("memory/facts.md") or ""
self.ctx.write("memory/facts.md", f"{existing}\n\n### Discovered {timestamp}\n{new_facts.content}")
```
## Examples
### Example 1: Setting Up Agent Memory for a Web App Project
```python
ctx = ContextManager("./my-project-context")
# Initialize project context
ctx.write("project/README.md", "# E-commerce Platform\nNext.js + Postgres + Stripe")
ctx.write("memory/facts.md", "- Database: PostgreSQL 16\n- Auth: NextAuth with Google OAuth")
ctx.write("memory/preferences.md", "- Use TypeScript strict mode\n- Prefer server components")
ctx.write("skills/coding-style.md", "- camelCase variables\n- Zod for validation")
# Agent reads scoped context for a task
scoped = ScopedContext(ctx)
context = scoped.get_context(scope="task")
# Returns: project README + facts + preferences + coding style + current task
```
### Example 2: LangChain Tool Integration
```python
from langchain_core.tools import tool
ctx = ContextManager("./agent-context")
@tool
def read_context(path: str) -> str:
"""Read a context file to recall project info, decisions, or lessons."""
return ctx.read(path) or f"No context at {path}"
@tool
def write_context(path: str, content: str) -> str:
"""Save learnings, decisions, or facts to context."""
ctx.write(path, content, metadata={"source": "agent"})
return f"Written to {path}"
@tool
def search_context(query: str) -> str:
"""Search all context files for relevant information."""
results = ctx.search(query)
return "\n".join(f"[{p}] ...{s}..." for p, s in results[:5]) or "No matches."
tools = [read_context, write_context, search_context]
```
## Guidelines
1. **Scope aggressively** — Don't load all context every time. Use hierarchical scoping to keep prompts focused
2. **Metadata headers** — Add timestamps and source info to context files for auditability
3. **Soft delete** — Move to `.trash` instead of deleting. Context that seems useless now may matter later
4. **Token budgeting** — Set a max token budget per scope level. Compact if exceeded
5. **Version context** — Use git or timestamps to track how context evolves over time
6. **Separate facts from opinions** — Keep factual knowledge separate from preferences and lessons
7. **Periodic cleanup** — Run compaction weekly. Archive context not accessed in 30 days
## Dependencies
```bash
pip install langchain-core langchain-openai # For LangChain integration
# No external deps needed for core ContextManager — it's pure Python + filesystem
```Related Skills
zustand
You are an expert in Zustand, the small, fast, and scalable state management library for React. You help developers manage global state without boilerplate using Zustand's hook-based stores, selectors for performance, middleware (persist, devtools, immer), computed values, and async actions — replacing Redux complexity with a simple, un-opinionated API in under 1KB.
zoho
Integrate and automate Zoho products. Use when a user asks to work with Zoho CRM, Zoho Books, Zoho Desk, Zoho Projects, Zoho Mail, or Zoho Creator, build custom integrations via Zoho APIs, automate workflows with Deluge scripting, sync data between Zoho apps and external systems, manage leads and deals, automate invoicing, build custom Zoho Creator apps, set up webhooks, or manage Zoho organization settings. Covers Zoho CRM, Books, Desk, Projects, Creator, and cross-product integrations.
zod
You are an expert in Zod, the TypeScript-first schema declaration and validation library. You help developers define schemas that validate data at runtime AND infer TypeScript types at compile time — eliminating the need to write types and validators separately. Used for API input validation, form validation, environment variables, config files, and any data boundary.
zipkin
Deploy and configure Zipkin for distributed tracing and request flow visualization. Use when a user needs to set up trace collection, instrument Java/Spring or other services with Zipkin, analyze service dependencies, or configure storage backends for trace data.
zig
Expert guidance for Zig, the systems programming language focused on performance, safety, and readability. Helps developers write high-performance code with compile-time evaluation, seamless C interop, no hidden control flow, and no garbage collector. Zig is used for game engines, operating systems, networking, and as a C/C++ replacement.
zed
Expert guidance for Zed, the high-performance code editor built in Rust with native collaboration, AI integration, and GPU-accelerated rendering. Helps developers configure Zed, create custom extensions, set up collaborative editing sessions, and integrate AI assistants for productive coding.
zeabur
Expert guidance for Zeabur, the cloud deployment platform that auto-detects frameworks, builds and deploys applications with zero configuration, and provides managed services like databases and message queues. Helps developers deploy full-stack applications with automatic scaling and one-click marketplace services.
zapier
Automate workflows between apps with Zapier. Use when a user asks to connect apps without code, automate repetitive tasks, sync data between services, or build no-code integrations between SaaS tools.
zabbix
Configure Zabbix for enterprise infrastructure monitoring with templates, triggers, discovery rules, and dashboards. Use when a user needs to set up Zabbix server, configure host monitoring, create custom templates, define trigger expressions, or automate host discovery and registration.
yup
Validate data with Yup schemas. Use when adding form validation, defining API request schemas, validating configuration, or building type-safe validation pipelines in JavaScript/TypeScript.
yt-dlp
Download video and audio from YouTube and other platforms with yt-dlp. Use when a user asks to download YouTube videos, extract audio from videos, download playlists, get subtitles, download specific formats or qualities, batch download, archive channels, extract metadata, embed thumbnails, download from social media platforms (Twitter, Instagram, TikTok), or build media ingestion pipelines. Covers format selection, audio extraction, playlists, subtitles, metadata, and automation.
youtube-transcription
Transcribe YouTube videos to text using OpenAI Whisper and yt-dlp. Use when the user wants to get a transcript from a YouTube video, generate subtitles, convert video speech to text, create SRT/VTT captions, or extract spoken content from YouTube URLs.