---
name: chatondearu-cda-foam
description: "Bootstrap and maintain a Foam-style project memory graph (ADR, PRD, plans, foam/board) at repo-root foam/. Execution status is foam/board (ADR-016), not GitHub Projects. Use when starting project memory, recording architecture decisions, drafting PRDs/plans, one-shot mapping GH issues to board cards, or before product/architecture changes so the agent can challenge accepted ADRs."
metadata:
  decimalai-skill-id: "a011282b-3c2b-47c0-9889-879d25c24858"
  decimalai-version-id: "98d562da-90db-44fe-857e-1550c16a1d89"
  decimalai-version: "5"
  decimalai-body-sha256: "b51368367202d361d75c05587dcf93c7f5eedf3b25edbccc5d6697de6847c742"
  decimalai-name: "chatondearu/cda-foam"
  decimalai-format: "1"
  decimalai-invocation: "model"
  decimalai-category: "documentation"
  decimalai-source: "https://app.decimal.ai/s/chatondearu-cda-foam@5/SKILL.md"
---
# Foam project memory

## What this is

A **versioned knowledge graph** in Markdown (wikilinks `[[note]]`) so agents and
humans share the same memory:

| Layer | Path | Role |
| ----- | ---- | ---- |
| **Foam graph** | `foam/` | MOC, ADRs, product notes, feature catalog |
| **PRD** | `prd/` | What / why per feature |
| **Plan** | `plans/` | How / when (checklist derived from PRD) |
| **Kanban** | `foam/board/` | Execution status (ADR-016; use `cda-kanban`) |

**Board privacy:** one board = this repository. Never commit host paths,
other-project inventories, personal data, or secrets into `foam/board`
(or kit plans/ADRs that describe boards). Runtime discovery (`cdamux
projects`, `$CDAMUX_HOME`) stays on the operator machine.

`foam/` is **agent decision memory**. User-facing docs may live elsewhere (`doc/`,
`README.md`) — do not duplicate; link from `foam/` when needed.

## Bootstrap a repository

Prefer **`cda-agents`** for a full bootstrap (`AGENTS.md` + optional foam):

```bash
bash ~/.cursor/skills/cda-agents/scripts/setup-agents.sh --type auto --init-foam
```

Or foam scaffold only:

```bash
# preview
bash "$(dirname "$0")/scripts/init.sh" --dry-run

# scaffold (never commits — you git add/commit when ready)
bash "$(dirname "$0")/scripts/init.sh"

# import closed/open issues from GitHub into foam/features/
bash "$(dirname "$0")/scripts/import-kanban.sh"

# one-shot map of open GH issues → foam/board cards (not a loop)
bash "$(dirname "$0")/scripts/import-board.sh"
```

`init.sh` copies templates only. It does **not** run `git commit` — you decide
when to commit the scaffold. Existing paths are skipped; `--force` overwrites
template files in place and never deletes anything.

## Protocol (every product/architecture/design task)

Single source: `AGENTS.md`, rules and `cda-agents` summarize this and link here.

1. Read `AGENTS.md` and `foam/index.md` (Map of Content).
2. Search `foam/decisions/` for related ADRs (grep tags or keywords).
3. Search `prd/` and `plans/` for related specs.
4. Search **GitHub** for overlapping work before deciding or coding:
   ```bash
   gh issue list --state all --search "keywords" --limit 20
   gh pr list --state all --search "keywords" --limit 20
   ```
5. If an issue, PR, ADR, or PRD already covers the topic — read it and
   **confront** the new proposal with recorded decisions. Cite sources.
6. Check the **out-of-scope register** (`foam/features/out-of-scope.md`): if this
   feature was already ruled out, surface that decision (and its reason) instead of
   re-proposing it. Reopen only as a conscious, justified exception.
7. If the user requests something that **contradicts an accepted ADR**, cite the
   ADR and ask whether to supersede it (new ADR required).
8. After shipping or deciding: update foam, Kanban, `AGENTS.md`, and user-facing
   `doc/` (via `cda-docs`) when the change affects any of them.

## Workflows

### A — New feature

Issue → PRD → plan → PR: see `cda-plan` § End-to-end feature pipeline.

### B — Architecture decision

1. Copy `foam/decisions/ADR-template.md` → `foam/decisions/ADR-NNN-slug.md`.
2. Fill context, decision, **alternatives rejected**, consequences.
3. Add row to `foam/decisions/index.md` and `foam/index.md`.
4. Link from relevant `foam/architecture/*.md` notes.

### B2 — Rule a feature out of scope

When a feature request is **declined** (not deferred — genuinely ruled out),
append one entry to `foam/features/out-of-scope.md` (create it lazily) so the
decision is queryable and the same request doesn't resurface unchallenged:

```markdown
## <feature name>
- **Ruled out:** <date> — <who/where decided>
- **Why:** <the load-bearing reason a future proposer needs>
- **Revisit if:** <the condition that would reopen it, or "—">
- **Refs:** [[decisions/ADR-NNN-slug|ADR-NNN]] / #issue
```

This is the dedup register the agent protocol checks before proposing. A *rejected
alternative within a decision* still belongs in that ADR's "alternatives rejected";
out-of-scope.md is for whole features ruled beyond the product's scope. Don't dump
every "not now" here — only conscious scope decisions worth defending later.

### C — Sync shipped/backlog catalogs

```bash
bash scripts/import-kanban.sh          # refresh shipped + backlog indexes
bash scripts/import-kanban.sh --dry-run
```

Regenerates `foam/features/shipped.md` and `foam/features/backlog.md` from
`gh issue list`. Re-run after milestones or when onboarding a repo.

### C1 — One-shot map onto `foam/board/` (not a loop)

```bash
bash scripts/import-board.sh           # create missing foam/board/{N}-*.md
bash scripts/import-board.sh --dry-run
```

Maps open `gh issue list` rows to cards with `github_issue` set and
`status: backlog`. **Does not overwrite** existing cards. Run once when
adopting foam-first kanban, then stop writing GitHub Projects. Status after
that lives on the files (`cda-kanban` `foam-board.sh`).

### C2 — Doc layout verify

```bash
bash ~/.cursor/skills/cda-doc-hygiene/scripts/doc-hygiene.sh --check
bash ~/.cursor/skills/cda-doc-hygiene/scripts/doc-hygiene.sh --report --gh
```

Skill **cda-doc-hygiene** — catches misplaced Superpowers trees, broken plan links,
and closed issues still under `plans/`. See `foam/product/documentation-layout.md`.

### D — Import historical decisions (one-off)

For mature repos: read closed issues + CHANGELOG + `AGENTS.md` gotchas → distill
into ADRs and PRDs (do not dump every issue as an ADR).

## Integration with cda-kanban

| Kanban | Foam |
| ------ | ---- |
| `foam/board/*.md` | Execution status (SoT) |
| Optional `github_issue` | PRD source (`cda-prd`) |
| Status Ready | PRD `approved` + plan exists (`cda-plan`) |
| Status Done | PRD `shipped`, plan `done` |
| Epic / backlog | `foam/features/backlog.md` + PRDs |
| Claim + branch | Plan checklist drives tasks |

## Layout (repo root)

```
foam/
  index.md              # start here
  README.md
  board/                # execution status (one file per card; ADR-016)
  decisions/            # ADRs
  product/                # vision, rules
  features/               # shipped / backlog catalog
  architecture/           # topic guides (optional)
prd/
plans/
.foam/templates/          # Foam editor templates
.cursor/rules/
  product-memory.mdc      # project rule (copied on init)
```

## Additional material

- [conventions.md](conventions.md) — naming, statuses, tags
- [reference.md](reference.md) — ADR/PRD/plan templates explained
- [templates/scaffold/](templates/scaffold/) — files copied by `init.sh`
