Architecture foundation for a new project: discovers goals, constraints and quality drivers, then records product docs, ADRs and the IDD configuration. Trigger: new project, from scratch, define the architecture.
$npx -y skills add Snakeblack/ospec-workflow --skill foundation --agent claude-code
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Foundation?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/snakeblack-foundation)
---
name: foundation
description: "Architecture foundation for a new project: discovers goals, constraints and quality drivers, then records product docs, ADRs and the IDD configuration. Trigger: new project, from scratch, define the architecture."
license: MIT AND Commons-Clause
metadata:
author: manuel-retamozo-garcia
version: "2.0"
runtime_capabilities:
execute: false
mcp: true
write: true
---
## When to Use
Run foundation before the first code of a new project, or when a project has
code but no recorded product or architecture decisions and the user asks to
define them. It decides and records. It never writes application code,
manifests, dependencies, CI files or scaffolds: the first slice is built
afterwards as an ordinary change (IDD by default, SDD on request).
## How it runs
- **Direct** (the user, the router or IDD loads this skill): ask each round
yourself with the host's question tool; when the host has none, end your
turn with the questions and wait for the answer.
- **Delegated** (the SDD orchestrator launches the `foundation` agent): never
ask the user. Return `status: blocked` with a `question_gate` holding the
round; the orchestrator asks and relaunches you with the answers. In this
mode `openspec/config.yaml` must exist: if it is missing, return `blocked`
with next step `sdd-init`.
Either way, write every confirmed answer to disk before asking the next
round. The documents are the state, never the conversation.
## Think like an architect
- Start from the problem, the users and the constraints, not from technology.
- Drivers decide the architecture: the three to five quality attributes that
matter most, each as a scenario (source and stimulus, environment, response,
measure). Use a measure only when the user gives or confirms one; never
invent an SLA or a budget.
- Choose the simplest structure that meets the drivers. One team and one
deployable start as a modular monolith; split into services only for a named
driver (independent deployment or scaling, a team boundary, a fault or
regulatory isolation boundary) and record it.
- Decide now only what blocks the first slice or is costly to reverse: system
boundaries, data ownership (one owner per piece of data), integration style,
trust boundaries and contract evolution. Defer the rest with an owner and a
last responsible moment.
- Name every dependency and integration with its owner and its failure mode.
## Discovery rounds
1. Read what exists first: `docs/**`, ADRs, manifests, `idd/config.yaml`,
`openspec/config.yaml` and the sources the user supplies. Mark each fact
with its source.
2. Keep the knowledge map at `docs/architecture/knowledge-map.yaml`
(`ospec-knowledge-map/v1`, or `v2` once a quality scenario declares its
`fitness`). Each slot (business, functional, team, quality,
architecture, technology, operation, delivery) is `unknown`, `confirmed`
(with its source), `assumed` (with its source and what would change it),
`n/a` (with why it does not apply) or `deferred` (with an owner), and names
the decisions it feeds. `unknown` is not `n/a`. A quality scenario states
origin, stimulus, environment, artifact and response; add a measure only
when the user gives one, and record who gave it. In v2 its `fitness` holds
the `checks` commands that verify it (a benchmark, a budget) or a
`description` for a check by hand.
3. `ospec` below means `{{ospec-cli}}`, run from the project root.
Take the round from `ospec foundation next`. When the map does not exist
yet, pass `--profile` and write the returned `template` to
`docs/architecture/knowledge-map.yaml` before recording: `next` does not
create the file. Ask only the slots in that round, in that order, all in
the returned theme. The engine returns at most four questions per round.
Phrase each question for this project. Offer a
recommended answer aimed at `recommendation.unblocks`, plus "I don't know".
Record each answer with `ospec foundation record` before asking for the
next round. "I don't know" is `--state assumed` with a source and a
`--review-trigger`. Do not ask a slot the engine omitted.
4. Stop when `foundation next` returns an empty round, or earlier when every
slot that blocks the first slice is confirmed, assumed or deferred with an
owner. The whole future need not be settled.
## Brownfield recovery
When the project already has code, infer its architecture before asking and
let the user confirm or correct it. Every claim cites `path:line` evidence
that exists in the repository; a claim you cannot point at stays a question.
- Write `docs/architecture/component-map.yaml` (`ospec-component-map/v2`):
components, boundaries, dependencies between components, and divergences
where the code departs from the documentation, each with its evidence. A
divergence names the documented text in `documented` and leaves it as
written. Give each component the `paths` it owns as globs and, in
`knowledge`, the ids of the ADRs, quality scenarios, glossary terms and
constraint slots that govern it: IDD hands them to every change that
touches it.
- Propose each structural decision the code already embodies as an ADR with
`status: inferred` and its `evidence`. Ask the user about every one in the
rounds: confirmed or corrected, it becomes `accepted` and keeps its
evidence; rejected, it is not written and becomes a divergence with
`rejected_adr`.
- Record quality hints (timeouts, retries, caches, audit trails) as `assumed`
slots with a `repository` source `path:line` and a review trigger.
## Acceptance scenarios
Match one row and follow it. The notes in `assets/scenarios/` show the shape.
Do not write application code, manifests, dependencies, CI files or scaffolds
without approval.
| Case | Do | Do not |
| --- | --- | --- |
| CLI local without a service | Cover files, errors, compatibility, distribution and tests. | Load `cncf-landscape`. Treat Kubernetes as a requirement. |
| Small SaaS | Compare the simple existing or managed operation with alternatives. Record unknown cost and competencies. | Invent an SLO or any numeric budget. |
| Regulated or high-risk | Go deeper on data, permissions, traceability and recovery. | Confirm an obligation no competent source confirmed. Leave it a gap. |
| Documented brownfield | Read the baseline and its evidence. Record divergences and propose a focused delta. Preserve prior content and the approval already in force. Recover what the baseline does not record (Brownfield recovery). | Accept an ADR with `status: inferred` without the user's answer. Overwrite prior text. |
| Stale source or offline | Show the revision or date and what is unknown. Leave unknown only the decision that depends on the missing evidence. Use the existing `unknown` or `assumed` slot. | Stop the decisions that do not depend on that source. Add a stale state to the knowledge map. |
| Small later change | Read the applicable sections and write only the delta. | Regenerate foundation. Run a general technology search. |
Load `cncf-landscape` only when a decision needs application delivery,
observability, containers, orchestration or platform services and no
well-supported alternative is recorded, or when the user asks to explore CNCF.
A local CLI, a language choice or bootstrap does not load it. Loading it does
not adopt a project.
## Outputs
Read each file before writing and update it; never discard what the user wrote.
| File | Content |
| --- | --- |
| `docs/product/brief.md` | Problem, users, goals, success measures, non-goals |
| `docs/product/functional-scope.md` | Actors, journeys, first slice, exclusions |
| `docs/product/glossary.md` | Domain terms |
| `docs/architecture/technical-baseline.md` | Context and boundaries, components and data ownership, integrations, quality scenarios, constraints, test strategy by risk, technology record |
| `docs/architecture/decisions/NNNN-<title>.md` | One ADR per structural decision |
| `docs/roadmap.md` | The first slice as a walking skeleton, then milestones; deferred decisions with their last responsible moment |
| `docs/architecture/knowledge-map.yaml` | The knowledge map and its open gaps |
| `docs/architecture/component-map.yaml` | Brownfield only: the recovered components, boundaries, dependencies and divergences |
Every ADR holds its context and drivers, at least two considered options, the
decision, its consequences (including what gets harder), a fitness function or
check that would detect a violation, and a review trigger. When a command can
detect the violation, add it as a `- Check:` line of the fitness function:
`ospec check` runs it for every IDD change that touches the ADR and refuses
the close while it fails. Cite at least one
driver id: a quality scenario, a constraint or an assumption. Its decision names
no product or library: technology choices go to the technology record, each
implementing an ADR and justified by team context, maturity, license, cost and
a dated source. Never rewrite an accepted ADR: supersede it with a new one.
A development decision stays in the change's living document; do not file it
as an ADR. With cross-session memory tools, keep each ADR and technology
record you write in memory as `references/foundation-details.md` (Memory)
describes; the files stay the authority.
The test strategy names what each layer protects: unit tests for domain
rules, validation and transformations; integration or contract tests for
boundaries and data access; measurements for performance drivers. It sets no
coverage percentage.
## Hand-off to IDD
Finish with the configuration that lets the first change derive the right
obligations. Propose it to the user and write `idd/config.yaml` only after
explicit approval, preserving its other keys:
- `checks:` the commands that prove a change (tests, lint, typecheck), which
run once the scaffold exists;
- `team:` the team profile from the team round (`size: solo | small |
multi-team`, `experience: junior | mixed | senior`): `ospec team` derives
delivery, review, Strict TDD and mentorship from it, so add `strict_tdd:`
only when the user's testing bar departs from that default;
- `impact:` the paths of public contracts, persistent data and security
boundaries in the chosen layout, plus `stack:` when services keep their
manifests below the root;
- `contracts.documents:` where contract documents (OpenAPI, proto, schemas)
live;
- `delivery:` how changes reach the repository, asked once the keys above
are written: run `ospec team`, which reads that profile, and present its
`branching`, `changelog` and `release`, each with its source, its reasons
and the alternatives with their tradeoffs: `serial` (one pull request in
flight) or `parallel` (several branches, each integrating the default
branch before its merge); a changelog path or `none`; `per-change`,
`batched` or `none`. Ask the `language` too, as a tag (`es`, `en`,
`pt-BR`): the one the project's commits, pull requests, changelog,
documentation and code comments are written in, which no profile decides;
recommend the one the user writes in. Add `integration_branch` only when
the team integrates apart from production. `ospec close` writes the changelog and proposes a
release only once they are declared. The delivery strategy `ospec team`
names follows from `team.size`: changing it means changing the size. A
`delivery:` already declared keeps its values unless the user changes them.
An IDD change declares the ADRs of `docs/architecture/decisions/` and the
quality scenarios it touches (`ospec signals --adr <id> --quality <id>`) and
its impact on each, so a later change that amends, supersedes or contradicts
an ADR stops for the user at the `adr-amend-or-contradict` gate. When the
project uses SDD, also update `openspec/config.yaml`, its own `team:`
included, as `references/foundation-details.md` describes.
Then settle where the work goes. Outside a git repository, offer
`git init -b main`. Without a remote (`git remote -v`), ask whether to create
one and where (for example `gh repo create --private` for closed code) or to
work without pull requests; without them `delivery:` is still declared and
commits go to the default branch. Last, offer to commit the foundation's
files (`docs/`, `idd/config.yaml`, `openspec/` when it exists) as one
Conventional Commit, such as `docs: add architecture foundation`. On a branch
with no commit yet (`git rev-parse --verify HEAD` fails), propose its name
(`main`) too: the first IDD change needs that base commit for its
counterproof. With history, propose the commit, or a branch and a pull
request as the approved delivery says. Run no `git init`, `git commit`, push
or remote creation without the user's explicit yes. Delegated, run none of
them: list in `open_questions` the `delivery:` question, answered from
`ospec team` once `team:` is written, the remote question and the commit
offer, for the orchestrator to ask and run.
## Source documents
Read text and Markdown sources directly. For PDF, Office or other binary
documents, use an available MarkItDown `convert_to_markdown` MCP tool, whatever
its server prefix; keep the original under `docs/references/raw/` and the
converted text under `docs/references/processed/` with its source, the useful
facts, the noise removed and the open questions. Without such a tool, never
install or register a server yourself: ask the user to paste or convert the
document, or skip it. A failed conversion skips only that document.
## Federated workspace
Delegated with `workspace_yaml` (the atlas `openspec/workspace.yaml`) and
`parent_change`, read each initialized member's
`{member}/openspec/specs/**/spec.md` and `{member}/docs/roadmap.md`, then:
- consolidate the members' milestones into `docs/roadmap.md`, by member;
- add to `technical-baseline.md` the section
**"Mapa de Contratos e Interacciones"**: the contracts each member
`provides` and their `consumers`;
- catalog in `docs/roadmap-gaps.md` the functional gaps (scope no member
covers) and the technical gaps (deviations from
`docs/architecture/shared-baseline.md`, provider and consumer mismatches).
Unresolved gaps block: return a `question_gate` whose options include
assigning the capability to a member, deferring it, or creating a member. The
orchestrator records the resolution (`skills/_shared/gaps-resolution.md`) and
relaunches you to finish both roadmaps.
## Result
Direct: summarize the decisions, the ADRs written, the open gaps, the
delivery and the commit, and the first slice, and recommend building that
slice as an IDD change. Delegated: return
`status`, `executive_summary`, `artifacts`, `next_recommended` (`sdd-new` for
the first slice; never continue into other phases), `risks`,
`open_questions` and `skill_resolution`, plus the `question_gate` when
blocked.