Python utility API for storing and retrieving project context in Obsidian vault markdown notes
Stores codebase context (file analyses, patterns, decisions) as Obsidian markdown notes. Use when analyzing files, documenting architectural decisions, or searching for reusable patterns.
/plugin marketplace add resolve-io/.prism/plugin install prism-devtools@prismThis skill inherits all available tools. When active, it can use any tool Claude has access to.
reference/commands.mdreference/integration.mdrequirements.txtutils/init_vault.pyutils/memory_intelligence.pyutils/storage_obsidian.pyPython storage utilities for capturing codebase context as Obsidian markdown notes.
Pure utility functions for storing/retrieving context:
Storage: Markdown files in Obsidian vault with YAML frontmatter
pip install python-frontmatter pyyaml
Set vault location in core-config.yaml:
memory:
enabled: true
storage_type: obsidian
vault: ../docs/memory
Or via environment variable:
PRISM_OBSIDIAN_VAULT=../docs/memory
python skills/context-memory/utils/init_vault.py
Creates folder structure:
docs/memory/PRISM-Memory/
├── Files/ # File analyses
├── Patterns/ # Code patterns
├── Decisions/ # Architecture decisions
└── Commits/ # Git history
from skills.context_memory.utils.storage_obsidian import (
store_file_analysis,
store_pattern,
store_decision,
recall_query,
recall_file,
get_memory_stats
)
Store analysis of a source file.
store_file_analysis(
file_path: str, # Relative path from project root
summary: str, # Brief description
purpose: str, # What it does
complexity: str, # simple|moderate|complex
key_functions: List[str] = None, # Important functions
dependencies: List[str] = None, # External dependencies
notes: str = None # Additional context
)
Example:
store_file_analysis(
file_path='src/auth/jwt-handler.ts',
summary='JWT token validation and refresh',
purpose='Handles authentication tokens',
complexity='moderate',
key_functions=['validateToken', 'refreshToken', 'revokeToken'],
dependencies=['jsonwebtoken', 'crypto'],
notes='Uses RSA256 signing'
)
Output: docs/memory/PRISM-Memory/Files/src/auth/jwt-handler.md
Store reusable code pattern.
store_pattern(
name: str, # Pattern name
description: str, # What it does
category: str, # Pattern type
example_path: str = None, # Where used
code_example: str = None, # Code snippet
when_to_use: str = None # Usage guidance
)
Example:
store_pattern(
name='Repository Pattern',
description='Encapsulates data access logic in repository classes',
category='architecture',
example_path='src/repos/user-repository.ts',
when_to_use='When abstracting database operations'
)
Output: docs/memory/PRISM-Memory/Patterns/architecture/repository-pattern.md
Record architectural decision.
store_decision(
title: str, # Decision title
decision: str, # What was decided
context: str, # Why it matters
alternatives: str = None, # Options considered
consequences: str = None # Impact/tradeoffs
)
Example:
store_decision(
title='Use JWT for Authentication',
decision='Implement stateless JWT tokens instead of server sessions',
context='Need to scale API horizontally across multiple servers',
alternatives='Considered Redis sessions but adds dependency',
consequences='Tokens cannot be revoked until expiry'
)
Output: docs/memory/PRISM-Memory/Decisions/YYYYMMDD-use-jwt-for-authentication.md
Search all stored context.
recall_query(
query: str, # Search terms
limit: int = 10 # Max results
) -> List[Dict]
Returns:
[
{
'type': 'file', # file|pattern|decision
'path': 'src/auth/jwt-handler.ts',
'summary': 'JWT token validation...',
'content': '...' # Full markdown content
},
...
]
Example:
results = recall_query('authentication JWT')
for result in results:
print(f"{result['type']}: {result['path']}")
print(f" {result['summary']}")
Get analysis for specific file.
recall_file(file_path: str) -> Optional[Dict]
Returns:
{
'path': 'src/auth/jwt-handler.ts',
'summary': '...',
'purpose': '...',
'complexity': 'moderate',
'key_functions': [...],
'last_analyzed': '2025-01-05'
}
Example:
analysis = recall_file('src/auth/jwt-handler.ts')
if analysis:
print(f"Complexity: {analysis['complexity']}")
Get vault statistics.
get_memory_stats() -> Dict
Returns:
{
'files_analyzed': 42,
'patterns_stored': 15,
'decisions_recorded': 8,
'total_notes': 65,
'vault_path': '/path/to/docs/memory'
}
All notes use YAML frontmatter + markdown body:
---
type: file_analysis
path: src/auth/jwt-handler.ts
analyzed_at: 2025-01-05T10:30:00
complexity: moderate
tags:
- authentication
- security
---
# JWT Handler
Brief description of the file...
## Purpose
What this file does...
## Key Functions
- validateToken()
- refreshToken()
skills/context-memory/
├── SKILL.md # This file
├── reference/
│ ├── commands.md # Complete API reference
│ └── integration.md # Integration examples
└── utils/
├── init_vault.py # Initialize vault
├── storage_obsidian.py # Storage functions
└── memory_intelligence.py # Confidence/decay utilities
Vault not found:
python skills/context-memory/utils/init_vault.py
Import errors:
pip install python-frontmatter pyyaml
Path issues:
.prism/ folderVersion: 1.7.1 - Pure utility API for Obsidian storage
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.