Intermediate~20 minTeam & Multi-Project

Monorepo Knowledge Sharing

Import and sync docs across multiple packages using the Knowns import system.

ImportSyncMonorepo
Shared source
Configure imports
knowns sync
kn-research
AI uses shared context

The problem

In a monorepo, each package has its own context. Your AI assistant in packages/api doesn't know about patterns documented in packages/shared. You end up re-explaining the same conventions in every session.


Set Up the Shared Source

Create a shared Knowns project with your team's docs:

cd packages/shared
knowns init

knowns doc create "API conventions" \
  --folder patterns \
  --content "## API Conventions\n\n- Use REST with JSON\n- Always return { data, error, meta }"

knowns doc create "Error handling" \
  --folder patterns \
  --content "## Error Handling\n\n- Use custom AppError class\n- Always include error code"
File structure
monorepo/
├── packages/
│   ├── shared/
│   │   └── .knowns/
│   │       └── docs/
│   │           └── patterns/
│   │               ├── api-conventions.md
│   │               └── error-handling.md
│   ├── api/
│   │   └── .knowns/        ← will import from shared
│   └── web/
│       └── .knowns/        ← will import from shared

Configure Imports in Consumer Packages

In each package that needs the shared docs, edit .knowns/config.json:

{
  "imports": [
    {
      "name": "shared-patterns",
      "source": "../shared/.knowns/docs",
      "type": "local",
      "include": ["patterns/**"]
    }
  ]
}

Cross-repo imports

For separate repos, use Git or npm sources:

{
  "imports": [
    {
      "name": "team-standards",
      "source": "https://github.com/your-org/standards.git",
      "type": "git",
      "path": ".knowns/docs",
      "include": ["patterns/**"]
    }
  ]
}

Sync

knowns sync
Sync output
Syncing shared-patterns...
✓ Imported patterns/api-conventions.md
✓ Imported patterns/error-handling.md
2 docs synced

Imported docs appear in .knowns/imports/ and are available to AI via MCP and search.

Use Shared Context

Now when your AI works in packages/api, it has access to shared patterns:

AI using shared context
You: Create an endpoint following our API conventions

AI:  [Reads @doc/patterns/api-conventions via MCP]
   I see your conventions require:
   - REST with JSON responses
   - { data, error, meta } response shape
   - Correct HTTP status codes

   Creating the endpoint...

Share Templates Too

Templates can also be shared:

cd packages/shared
knowns template create api-endpoint \
  --description "Standard REST endpoint with error handling"

Consumer packages import and use them:

cd packages/api
knowns sync
knowns template run api-endpoint --name users

Keeping Things in Sync

Auto-sync on init

Add to your workflow — run sync at session start:

knowns sync && knowns init

Selective Imports

Use include and exclude patterns to control what gets imported:

{
  "imports": [
    {
      "name": "shared",
      "source": "../shared/.knowns/docs",
      "type": "local",
      "include": ["patterns/**"],
      "exclude": ["patterns/internal/**"]
    }
  ]
}

Key Takeaways

Without shared knowledgeWith Knowns imports
Re-explain conventions in every packageDocument once, share everywhere
AI doesn't know about shared patternsImported docs are searchable via MCP
Manual copy-paste of templatesSync from local, Git, or npm sources
All-or-nothing sharingSelective import with include/exclude

What's next?

Read the Import System docs for the full reference, or check out Templates for code generation patterns.