bastion/life-log
Skill8 starsChanged 4 months agoMITView on GitHub
Records persona interactions with vector embeddings and enables semantic search (RAG) over history. Persists in local SQLite (default) or Supabase (optional via DB_STRATEGY). Zero external dependencies — works offline with 100% user-controlled data.
- Reads credentials
In this repository17 other files it gives its agents.
- bastion/agentskills-installSkill
- bastion/agentskills-publishSkill
- bastion/calendarSkill
- bastion-pet-packSkill
- bastion/channel-scaffoldSkill
- bastion/crisis-modeSkill
- mcporterSkill
- bastion/mesh-connectSkill
- bastion/mobile-connectSkill
- bastion/onboardingSkill
- bastion/output-validatorSkill
- bastion/persona-engineSkill
- bastion/proactive-engineSkill
- bastion/self-improvingSkill
- bastion/skill-writerSkill
- bastion/weekly-reviewSkill
- bastion/weight-systemSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 129
No skill code needs to change.
- Very specific: line 168
When the sqlite-vec extension is installed, it is loaded automatically for native vector search.
- Very specific: line 255
If no record reaches the threshold, search_similar returns an empty list.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: bastion/life-log
Objective
Maintain a semantic history of interactions per persona, allowing Bastion to:
- Remember past conversations without user needing to repeat context
- Search most relevant records to enrich responses (RAG)
- Analyze usage patterns per persona over time
- Detect inactive personas for proactive suggestions
CLI Commands
IMPORTANT: CLI Command When running inside Bastion, invoke these operations through the declared tool interface. Do not simulate tool results.
from skills.life_log.factory import Settings, create_adapter
from datetime import datetime, timezone
# Instantiate via factory (reads DB_STRATEGY from environment)
settings = Settings.from_env()
adapter = create_adapter(settings)
# Log an interaction
interaction_id = await adapter.log_interaction(
persona="tech-lead",
intent="code-review",
tools=["github-integration", "code-review-helper"],
embedding=[0.1, 0.2, ...], # generated by the configured LLM
timestamp=datetime.now(tz=timezone.utc),
)
# Semantic search (RAG)
similar = await adapter.search_similar(
query_embedding=[0.1, 0.2, ...],
persona="tech-lead", # None to search across all personas
limit=5,
threshold=0.65,
)
# Summary of last 7 days
summary = await adapter.get_persona_summary(
persona="tech-lead",
days=7,
)Required Fields for Each Record
| Field | Type | Description |
id | str (UUID) | Unique identifier generated automatically |
persona | str | Slug of active persona in interaction |
intent | str | Executed intent (e.g., "code-review", "deploy-check") |
tools | list[str] | Names of tools used in interaction |
embedding | list[float] | Input embedding vector (generated by LLM) |
timestamp | datetime | UTC date/time of interaction |
Semantic Search
Threshold and Limit
- default threshold:
0.65— only results with cosine similarity ≥ 0.65 - default limit:
5— maximum 5 results per search - Results ordered by descending similarity
Embedding Generation
Embeddings are generated by the provider configured in Bastion. The skill doesn't generate embeddings directly — receives the vector already calculated by orchestrator.
Context Injection in Prompt
The orchestrator uses search_similar before assembling each response:
1. Generate embedding from user input
2. Call search_similar(query_embedding, persona=active_persona, limit=5, threshold=0.65)
3. Inject returned records as historical context into the system prompt
4. Respond with enriched contextDB_STRATEGY Pattern
The skill uses the Protocol/Adapter (hexagonal) pattern to decouple business logic from the persistence backend.
Switching from SQLite to Supabase
Just change one variable in .env:
# Default — local SQLite, zero external dependency
DB_STRATEGY=sqlite
SQLITE_PATH=db/life-log.db
# Optional — Supabase (PostgreSQL + pgvector)
DB_STRATEGY=supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-or-service-keyNo skill code needs to change. The factory (create_adapter) instantiates the correct adapter based on DB_STRATEGY.
Available Adapters
| DB_STRATEGY | Adapter | Dependency |
sqlite (default) | SQLiteLifeLogAdapter | None (stdlib) |
supabase | SupabaseLifeLogAdapter | supabase-py + Supabase project |
SQLite Persistence
Database Location
db/life-log.db ← created automatically on first writeThe db/ directory is created automatically if it doesn't exist.
Schema
CREATE TABLE interactions (
id TEXT PRIMARY KEY, -- UUID v4
persona TEXT NOT NULL, -- persona slug
intent TEXT NOT NULL, -- executed intent
tools TEXT NOT NULL, -- JSON array of tool names
embedding BLOB NOT NULL, -- float32 little-endian
timestamp TEXT NOT NULL -- ISO 8601 UTC
);
CREATE INDEX idx_interactions_persona ON interactions (persona);
CREATE INDEX idx_interactions_timestamp ON interactions (timestamp);sqlite-vec
When the sqlite-vec extension is installed, it is loaded automatically for native vector search. If not available, the adapter falls back to pure-Python cosine similarity — works offline with no native dependencies.
Architecture (Hexagonal)
LifeLogProtocol (port)
├── log_interaction(persona, intent, tools, embedding, timestamp) → str
├── search_similar(query_embedding, persona, limit, threshold) → list[InteractionRecord]
└── get_persona_summary(persona, days) → list[InteractionRecord]
SQLiteLifeLogAdapter (default adapter)
├── Creates db/life-log.db automatically
├── Uses sqlite-vec when available
└── Falls back to pure-Python cosine similarity
SupabaseLifeLogAdapter (optional adapter)
├── Uses supabase-py + pgvector
└── Stub — requires full implementation for production
Settings + create_adapter() (factory)
└── Instantiates the correct adapter based on DB_STRATEGYWhen This Skill is Triggered
1. Interaction Logging (after each response)
The orchestrator calls log_interaction at the end of each relevant interaction:
await adapter.log_interaction(
persona=active_persona.slug,
intent=detected_intent,
tools=tools_used,
embedding=await llm.embed(user_input),
timestamp=datetime.now(tz=timezone.utc),
)2. Semantic Search (before each response)
The orchestrator enriches context before responding:
context = await adapter.search_similar(
query_embedding=await llm.embed(user_input),
persona=active_persona.slug,
limit=5,
threshold=0.65,
)
# Inject context into system prompt3. Weekly Review (HEARTBEAT — every Monday at 9am)
summary = await adapter.get_persona_summary(persona=slug, days=7)
# Analyze patterns, suggest weight adjustments4. Inactivity Detection (HEARTBEAT — every 6h)
for persona in all_personas:
recent = await adapter.get_persona_summary(persona=persona.slug, days=3)
if not recent:
# Generate resumption suggestionEdge Cases
Database doesn't exist on first read
The SQLiteLifeLogAdapter creates the file and schema automatically before any operation. No manual initialization required.
Embedding with different dimension
search_similar compares embeddings using cosine similarity. If vectors have different dimensions, a ValueError is raised. Always use the same embedding model.
Threshold too high (no results)
If no record reaches the threshold, search_similar returns an empty list. The orchestrator must handle this case and respond without historical context.
Persona with no history
get_persona_summary returns an empty list for personas with no interactions in the period. This is not an error — it indicates a new or inactive persona.
Output Example
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"persona": "tech-lead",
"intent": "code-review",
"tools": ["github-integration", "code-review-helper"],
"timestamp": "2024-01-15T10:30:00Z"
}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

