AI Agent Guide

Protocols for AI agents working with Knowns

AI Agent Guide

Protocols and rules for AI assistants working with Knowns CLI and MCP.

Core Rules

1. CLI-Only Operations

Never edit .md files directly. All modifications must use CLI or MCP:

bash
# ✅ Correct
knowns task edit 42 --check-ac 1

# ❌ Wrong - Never edit files directly
# Edit .knowns/tasks/task-42.md

2. Always Use --plain

Machine-readable output for all read operations:

bash
knowns task list --plain
knowns task 42 --plain
knowns doc "README" --plain
knowns search "auth" --plain

Note: --plain is only for read commands (view, list, search). Not for create/edit.

3. Always Use --smart for Docs

Auto-handles both small and large documents:

bash
knowns doc "README" --plain --smart
  • ≤2000 tokens → full content
  • >2000 tokens → stats + TOC, then use --section N

4. MCP Preferred (v0.20 Consolidated Tools)

When MCP is available, use consolidated action-based tools:

JavaScript
// MCP (preferred) - v0.20 consolidated format
tasks({ action: "get", taskId: "42" })
tasks({ action: "update", taskId: "42", checkAc: [1] })

// CLI (fallback)
knowns task 42 --plain
knowns task edit 42 --check-ac 1

The -a Flag Warning

CRITICAL: -a means different things in different commands!

Command-a MeansNOT This
task create/edit--assigneeacceptance criteria
doc edit--appendassignee
bash
# ❌ WRONG (sets assignee to garbage!)
knowns task edit 42 -a "Criterion text"

# ✅ CORRECT (use --ac)
knowns task edit 42 --ac "Criterion text"

Workflow Selection

Choose based on task size:

FlowUse WhenCommand
Full SDDLarge features/kn-init/kn-spec/kn-plan/kn-implement/kn-verify
NormalSmall features/kn-init/kn-plan/kn-implement
Quick FixBug fixes/kn-init/kn-implement

See Workflow Guide for details.


Context Gathering

Before implementing, gather full context:

bash
# 1. Read task
knowns task 42 --plain

# 2. Follow ALL references in task
# If task mentions @doc/patterns/auth:
knowns doc "patterns/auth" --plain --smart

# If task mentions @task-15:
knowns task 15 --plain

# If task has spec: field:
knowns doc "specs/user-auth" --plain --smart

# 3. Search for related docs
knowns search "auth" --type doc --plain

Context Checklist

Before writing code, verify:

  • Read all @doc/... references
  • Read all @task-... references
  • Read linked spec (if spec: field exists)
  • Understand project architecture
  • Know coding conventions

SDD Integration

Task-Spec Linking

Tasks can link to specs via spec: field:

YAML
---
id: task-42
title: Implement login
spec: specs/user-auth # Links to @doc/specs/user-auth
---

AC Auto-Sync

When you check an AC on a task linked to a spec, the matching AC in the spec is automatically updated.

bash
# This updates both task AC and spec AC
knowns task edit 42 --check-ac 1

Verify Coverage

bash
knowns validate --sdd

Common Mistakes

❌ Wrong✅ Right
Edit .md files directlyUse CLI/MCP commands
-a "criterion" for AC--ac "criterion"
Skip reading docsRead ALL referenced docs
Code before plan approvalWait for user approval
Forget --plainAlways use --plain for reads
Check AC before work doneCheck AC AFTER completing work
Forget time trackingtime start → work → time stop
Use notes for updatesUse appendNotes for progress

MCP Tools Reference (v0.20 Consolidated)

ToolKey Actions
projectdetect, set, current, status
taskslist, get, create, update, delete, board
docslist, get, create, update, delete
memoryadd, get, list, update, delete, promote
searchsearch, retrieve, resolve
timestart, stop, add, report
templateslist, get, run, create
codesearch, symbols, deps, graph
validateValidate references, SDD coverage

Guidelines System

Get context-aware guidelines:

bash
# Full guidelines
knowns agents guideline

# Compact (core rules only)
knowns agents guideline --compact

# Stage-specific
knowns agents guideline --stage execution

Sync to AI Files

bash
# Sync skills + instructions to platform dirs
knowns sync

# Sync skills only
knowns sync --skills

# Sync instructions only
knowns sync --instructions