loki-mode — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited loki-mode (Agent Skill) and scored it 96/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 1 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 1 flagged
The text {match} tells the agent to skip the normal "ask the user first" gate. Used adversarially it removes the human-in-the-loop check before destructive or sensitive actions, turning a normally-gated agent into a fire-and-forget executor.
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Version 2.35.0 | PRD to Production | Zero Human Intervention Research-enhanced: OpenAI SDK, DeepMind, Anthropic, AWS Bedrock, Agent SDK, HN Production (2025)
.loki/CONTINUITY.md - Your working memory + "Mistakes & Learnings".loki/memory/ (episodic patterns, anti-patterns).loki/state/orchestrator.json - Current phase/metrics.loki/queue/pending.json - Next tasks| File | Purpose | Update When |
|---|---|---|
.loki/CONTINUITY.md | Working memory - what am I doing NOW? | Every turn |
.loki/memory/semantic/ | Generalized patterns & anti-patterns | After task completion |
.loki/memory/episodic/ | Specific interaction traces | After each action |
.loki/metrics/efficiency/ | Task efficiency scores & rewards | After each task |
.loki/specs/openapi.yaml | API spec - source of truth | Architecture changes |
CLAUDE.md | Project context - arch & patterns | Significant changes |
.loki/queue/*.json | Task states | Every task change |
START
|
+-- Read CONTINUITY.md ----------+
| |
+-- Task in-progress? |
| +-- YES: Resume |
| +-- NO: Check pending queue |
| |
+-- Pending tasks? |
| +-- YES: Claim highest priority
| +-- NO: Check phase completion
| |
+-- Phase done? |
| +-- YES: Advance to next phase
| +-- NO: Generate tasks for phase
| |
LOOP <-----------------------------+Bootstrap -> Discovery -> Architecture -> Infrastructure
| | | |
(Setup) (Analyze PRD) (Design) (Cloud/DB Setup)
|
Development <- QA <- Deployment <- Business Ops <- Growth Loop
| | | | |
(Build) (Test) (Release) (Monitor) (Iterate)Spec-First: OpenAPI -> Tests -> Code -> Validate Code Review: Blind Review (parallel) -> Debate (if disagree) -> Devil's Advocate -> Merge Guardrails: Input Guard (BLOCK) -> Execute -> Output Guard (VALIDATE) (OpenAI SDK) Tripwires: Validation fails -> Halt execution -> Escalate or retry Fallbacks: Try primary -> Model fallback -> Workflow fallback -> Human escalation Explore-Plan-Code: Research files -> Create plan (NO CODE) -> Execute plan (Anthropic) Self-Verification: Code -> Test -> Fail -> Learn -> Update CONTINUITY.md -> Retry Constitutional Self-Critique: Generate -> Critique against principles -> Revise (Anthropic) Memory Consolidation: Episodic (trace) -> Pattern Extraction -> Semantic (knowledge) Hierarchical Reasoning: High-level planner -> Skill selection -> Local executor (DeepMind) Tool Orchestration: Classify Complexity -> Select Agents -> Track Efficiency -> Reward Learning Debate Verification: Proponent defends -> Opponent challenges -> Synthesize (DeepMind) Handoff Callbacks: on_handoff -> Pre-fetch context -> Transfer with data (OpenAI SDK) Narrow Scope: 3-5 steps max -> Human review -> Continue (HN Production) Context Curation: Manual selection -> Focused context -> Fresh per task (HN Production) Deterministic Validation: LLM output -> Rule-based checks -> Retry or approve (HN Production) Routing Mode: Simple task -> Direct dispatch | Complex task -> Supervisor orchestration (AWS Bedrock) E2E Browser Testing: Playwright MCP -> Automate browser -> Verify UI features visually (Anthropic Harness)
# Launch with autonomous permissions
claude --dangerously-skip-permissionsThis system runs with ZERO human intervention.
These files are part of the running Loki Mode process. Editing them will crash the session:
| File | Reason |
|---|---|
~/.claude/skills/loki-mode/autonomy/run.sh | Currently executing bash script |
.loki/dashboard/* | Served by active HTTP server |
If bugs are found in these files, document them in .loki/CONTINUITY.md under "Pending Fixes" for manual repair after the session ends.
+-------------------------------------------------------------------+
| REASON: What needs to be done next? |
| - READ .loki/CONTINUITY.md first (working memory) |
| - READ "Mistakes & Learnings" to avoid past errors |
| - Check orchestrator.json, review pending.json |
| - Identify highest priority unblocked task |
+-------------------------------------------------------------------+
| ACT: Execute the task |
| - Dispatch subagent via Task tool OR execute directly |
| - Write code, run tests, fix issues |
| - Commit changes atomically (git checkpoint) |
+-------------------------------------------------------------------+
| REFLECT: Did it work? What next? |
| - Verify task success (tests pass, no errors) |
| - UPDATE .loki/CONTINUITY.md with progress |
| - Check completion promise - are we done? |
+-------------------------------------------------------------------+
| VERIFY: Let AI test its own work (2-3x quality improvement) |
| - Run automated tests (unit, integration, E2E) |
| - Check compilation/build (no errors or warnings) |
| - Verify against spec (.loki/specs/openapi.yaml) |
| |
| IF VERIFICATION FAILS: |
| 1. Capture error details (stack trace, logs) |
| 2. Analyze root cause |
| 3. UPDATE CONTINUITY.md "Mistakes & Learnings" |
| 4. Rollback to last good git checkpoint (if needed) |
| 5. Apply learning and RETRY from REASON |
+-------------------------------------------------------------------+CRITICAL: Use the right model for each task type. Opus is ONLY for planning/architecture.
| Model | Use For | Examples |
|---|---|---|
| Opus 4.5 | PLANNING ONLY - Architecture & high-level decisions | System design, architecture decisions, planning, security audits |
| Sonnet 4.5 | DEVELOPMENT - Implementation & functional testing | Feature implementation, API endpoints, bug fixes, integration/E2E tests |
| Haiku 4.5 | OPERATIONS - Simple tasks & monitoring | Unit tests, docs, bash commands, linting, monitoring, file operations |
# Opus for planning/architecture ONLY
Task(subagent_type="Plan", model="opus", description="Design system architecture", prompt="...")
# Sonnet for development and functional testing
Task(subagent_type="general-purpose", description="Implement API endpoint", prompt="...")
Task(subagent_type="general-purpose", description="Write integration tests", prompt="...")
# Haiku for unit tests, monitoring, and simple tasks (PREFER THIS for speed)
Task(subagent_type="general-purpose", model="haiku", description="Run unit tests", prompt="...")
Task(subagent_type="general-purpose", model="haiku", description="Check service health", prompt="...")# Launch 10+ Haiku agents in parallel for unit test suite
for test_file in test_files:
Task(subagent_type="general-purpose", model="haiku",
description=f"Run unit tests: {test_file}",
run_in_background=True)Background Agents:
# Launch background agent - returns immediately with output_file path
Task(description="Long analysis task", run_in_background=True, prompt="...")
# Output truncated to 30K chars - use Read tool to check full output fileAgent Resumption (for interrupted/long-running tasks):
# First call returns agent_id
result = Task(description="Complex refactor", prompt="...")
# agent_id from result can resume later
Task(resume="agent-abc123", prompt="Continue from where you left off")When to use `resume`:
Two dispatch modes based on task complexity - reduces latency for simple tasks:
| Mode | When to Use | Behavior |
|---|---|---|
| Direct Routing | Simple, single-domain tasks | Route directly to specialist agent, skip orchestration |
| Supervisor Mode | Complex, multi-step tasks | Full decomposition, coordination, result synthesis |
Decision Logic:
Task Received
|
+-- Is task single-domain? (one file, one skill, clear scope)
| +-- YES: Direct Route to specialist agent
| | - Faster (no orchestration overhead)
| | - Minimal context (avoid confusion)
| | - Examples: "Fix typo in README", "Run unit tests"
| |
| +-- NO: Supervisor Mode
| - Full task decomposition
| - Coordinate multiple agents
| - Synthesize results
| - Examples: "Implement auth system", "Refactor API layer"
|
+-- Fallback: If intent unclear, use Supervisor ModeDirect Routing Examples (Skip Orchestration):
# Simple tasks -> Direct dispatch to Haiku
Task(model="haiku", description="Fix import in utils.py", prompt="...") # Direct
Task(model="haiku", description="Run linter on src/", prompt="...") # Direct
Task(model="haiku", description="Generate docstring for function", prompt="...") # Direct
# Complex tasks -> Supervisor orchestration (default Sonnet)
Task(description="Implement user authentication with OAuth", prompt="...") # Supervisor
Task(description="Refactor database layer for performance", prompt="...") # SupervisorContext Depth by Routing Mode:
"Keep in mind, complex task histories might confuse simpler subagents." - AWS Best Practices
Critical: Features are NOT complete until verified via browser automation.
# Enable Playwright MCP for E2E testing
# In settings or via mcp_servers config:
mcp_servers = {
"playwright": {"command": "npx", "args": ["@playwright/mcp@latest"]}
}
# Agent can then automate browser to verify features work visuallyE2E Verification Flow:
"Claude mostly did well at verifying features end-to-end once explicitly prompted to use browser automation tools." - Anthropic Engineering
Note: Playwright cannot detect browser-native alert modals. Use custom UI for confirmations.
Inspired by NVIDIA ToolOrchestra: Track efficiency, learn from rewards, adapt agent selection.
| Metric | What to Track | Store In |
|---|---|---|
| Wall time | Seconds from start to completion | .loki/metrics/efficiency/ |
| Agent count | Number of subagents spawned | .loki/metrics/efficiency/ |
| Retry count | Attempts before success | .loki/metrics/efficiency/ |
| Model usage | Haiku/Sonnet/Opus call distribution | .loki/metrics/efficiency/ |
OUTCOME REWARD: +1.0 (success) | 0.0 (partial) | -1.0 (failure)
EFFICIENCY REWARD: 0.0-1.0 based on resources vs baseline
PREFERENCE REWARD: Inferred from user actions (commit/revert/edit)| Complexity | Max Agents | Planning | Development | Testing | Review |
|---|---|---|---|---|---|
| Trivial | 1 | - | haiku | haiku | skip |
| Simple | 2 | - | haiku | haiku | single |
| Moderate | 4 | sonnet | sonnet | haiku | standard (3 parallel) |
| Complex | 8 | opus | sonnet | haiku | deep (+ devil's advocate) |
| Critical | 12 | opus | sonnet | sonnet | exhaustive + human checkpoint |
See references/tool-orchestration.md for full implementation details.
Single-Responsibility Principle: Each agent should have ONE clear goal and narrow scope. (UiPath Best Practices)
Every subagent dispatch MUST include:
## GOAL (What success looks like)
[High-level objective, not just the action]
Example: "Refactor authentication for maintainability and testability"
NOT: "Refactor the auth file"
## CONSTRAINTS (What you cannot do)
- No third-party dependencies without approval
- Maintain backwards compatibility with v1.x API
- Keep response time under 200ms
## CONTEXT (What you need to know)
- Related files: [list with brief descriptions]
- Previous attempts: [what was tried, why it failed]
## OUTPUT FORMAT (What to deliver)
- [ ] Pull request with Why/What/Trade-offs description
- [ ] Unit tests with >90% coverage
- [ ] Update API documentation
## WHEN COMPLETE
Report back with: WHY, WHAT, TRADE-OFFS, RISKSNever ship code without passing all quality gates:
Guardrails Execution Modes:
Research insight: Blind review + Devil's Advocate reduces false positives by 30% (CONSENSAGENT, 2025). OpenAI insight: "Layered defense - multiple specialized guardrails create resilient agents."
See references/quality-control.md and references/openai-patterns.md for details.
Loki Mode has 37 specialized agent types across 7 swarms. The orchestrator spawns only agents needed for your project.
| Swarm | Agent Count | Examples |
|---|---|---|
| Engineering | 8 | frontend, backend, database, mobile, api, qa, perf, infra |
| Operations | 8 | devops, sre, security, monitor, incident, release, cost, compliance |
| Business | 8 | marketing, sales, finance, legal, support, hr, investor, partnerships |
| Data | 3 | ml, data-eng, analytics |
| Product | 3 | pm, design, techwriter |
| Growth | 4 | growth-hacker, community, success, lifecycle |
| Review | 3 | code, business, security |
See references/agent-types.md for complete definitions and capabilities.
| Issue | Cause | Solution |
|---|---|---|
| Agent stuck/no progress | Lost context | Read .loki/CONTINUITY.md first thing every turn |
| Task repeating | Not checking queue state | Check .loki/queue/*.json before claiming |
| Code review failing | Skipped static analysis | Run static analysis BEFORE AI reviewers |
| Breaking API changes | Code before spec | Follow Spec-First workflow |
| Rate limit hit | Too many parallel agents | Check circuit breakers, use exponential backoff |
| Tests failing after merge | Skipped quality gates | Never bypass Severity-Based Blocking |
| Can't find what to do | Not following decision tree | Use Decision Tree, check orchestrator.json |
| Memory/context growing | Not using ledgers | Write to ledgers after completing tasks |
Based on OpenAI Agent Safety Patterns:
opus -> sonnet -> haiku (if rate limited or unavailable)Full workflow fails -> Simplified workflow -> Decompose to subtasks -> Human escalation| Trigger | Action |
|---|---|
| retry_count > 3 | Pause and escalate |
| domain in [payments, auth, pii] | Require approval |
| confidence_score < 0.6 | Pause and escalate |
| wall_time > expected * 3 | Pause and escalate |
| tokens_used > budget * 0.8 | Pause and escalate |
See references/openai-patterns.md for full fallback implementation.
Read target project's AGENTS.md if exists (OpenAI/AAIF standard):
Context Priority:
1. AGENTS.md (closest to current file)
2. CLAUDE.md (Claude-specific)
3. .loki/CONTINUITY.md (session state)
4. Package docs
5. README.mdSelf-critique against explicit principles, not just learned preferences.
core_principles:
- "Never delete production data without explicit backup"
- "Never commit secrets or credentials to version control"
- "Never bypass quality gates for speed"
- "Always verify tests pass before marking task complete"
- "Never claim completion without running actual tests"
- "Prefer simple solutions over clever ones"
- "Document decisions, not just code"
- "When unsure, reject action or flag for review"1. Generate response/code
2. Critique against each principle
3. Revise if any principle violated
4. Only then proceed with actionSee references/lab-research-patterns.md for Constitutional AI implementation.
For critical changes, use structured debate between AI critics.
Proponent (defender) --> Presents proposal with evidence
|
v
Opponent (challenger) --> Finds flaws, challenges claims
|
v
Synthesizer --> Weighs arguments, produces verdict
|
v
If disagreement persists --> Escalate to humanUse for: Architecture decisions, security-sensitive changes, major refactors.
See references/lab-research-patterns.md for debate verification details.
Battle-tested insights from practitioners building real systems.
task_constraints:
max_steps_before_review: 3-5
characteristics:
- Specific, well-defined objectives
- Pre-classified inputs
- Deterministic success criteria
- Verifiable outputsconfidence >= 0.95 --> Auto-approve with audit log
confidence >= 0.70 --> Quick human review
confidence >= 0.40 --> Detailed human review
confidence < 0.40 --> Escalate immediatelyWrap agent outputs with rule-based validation (NOT LLM-judged):
1. Agent generates output
2. Run linter (deterministic)
3. Run tests (deterministic)
4. Check compilation (deterministic)
5. Only then: human or AI reviewprinciples:
- "Less is more" - focused beats comprehensive
- Manual selection outperforms automatic RAG
- Fresh conversations per major task
- Remove outdated information aggressively
context_budget:
target: "< 10k tokens for context"
reserve: "90% for model reasoning"Use sub-agents to prevent token waste on noisy subtasks:
Main agent (focused) --> Sub-agent (file search)
--> Sub-agent (test running)
--> Sub-agent (linting)See references/production-patterns.md for full practitioner patterns.
| Condition | Action |
|---|---|
| Product launched, stable 24h | Enter growth loop mode |
| Unrecoverable failure | Save state, halt, request human |
| PRD updated | Diff, create delta tasks, continue |
| Revenue target hit | Log success, continue optimization |
| Runway < 30 days | Alert, optimize costs aggressively |
.loki/
+-- CONTINUITY.md # Working memory (read/update every turn)
+-- specs/
| +-- openapi.yaml # API spec - source of truth
+-- queue/
| +-- pending.json # Tasks waiting to be claimed
| +-- in-progress.json # Currently executing tasks
| +-- completed.json # Finished tasks
| +-- dead-letter.json # Failed tasks for review
+-- state/
| +-- orchestrator.json # Master state (phase, metrics)
| +-- agents/ # Per-agent state files
| +-- circuit-breakers/ # Rate limiting state
+-- memory/
| +-- episodic/ # Specific interaction traces (what happened)
| +-- semantic/ # Generalized patterns (how things work)
| +-- skills/ # Learned action sequences (how to do X)
| +-- ledgers/ # Agent-specific checkpoints
| +-- handoffs/ # Agent-to-agent transfers
+-- metrics/
| +-- efficiency/ # Task efficiency scores (time, agents, retries)
| +-- rewards/ # Outcome/efficiency/preference rewards
| +-- dashboard.json # Rolling metrics summary
+-- artifacts/
+-- reports/ # Generated reports/dashboardsSee references/architecture.md for full structure and state schemas.
Loki Mode # Start fresh
Loki Mode with PRD at path/to/prd # Start with PRDSkill Metadata:
| Field | Value |
|---|---|
| Trigger | "Loki Mode" or "Loki Mode with PRD at [path]" |
| Skip When | Need human approval, want to review plan first, single small task |
| Related Skills | subagent-driven-development, executing-plans |
Detailed documentation is split into reference files for progressive loading:
| Reference | Content |
|---|---|
references/core-workflow.md | Full RARV cycle, CONTINUITY.md template, autonomy rules |
references/quality-control.md | Quality gates, anti-sycophancy, blind review, severity blocking |
references/openai-patterns.md | OpenAI Agents SDK: guardrails, tripwires, handoffs, fallbacks |
references/lab-research-patterns.md | DeepMind + Anthropic: Constitutional AI, debate, world models |
references/production-patterns.md | HN 2025: What actually works in production, context engineering |
references/advanced-patterns.md | 2025 research: MAR, Iter-VF, GoalAct, CONSENSAGENT |
references/tool-orchestration.md | ToolOrchestra patterns: efficiency, rewards, dynamic selection |
references/memory-system.md | Episodic/semantic memory, consolidation, Zettelkasten linking |
references/agent-types.md | All 37 agent types with full capabilities |
references/task-queue.md | Queue system, dead letter handling, circuit breakers |
references/sdlc-phases.md | All phases with detailed workflows and testing |
references/spec-driven-dev.md | OpenAPI-first workflow, validation, contract testing |
references/architecture.md | Directory structure, state schemas, bootstrap |
references/mcp-integration.md | MCP server capabilities and integration |
references/claude-best-practices.md | Boris Cherny patterns, thinking mode, ledgers |
references/deployment.md | Cloud deployment instructions per provider |
references/business-ops.md | Business operation workflows |
Version: 2.32.0 | Lines: ~600 | Research-Enhanced: Labs + HN Production Patterns
This skill is applicable to execute the workflow or actions described in the overview.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.