Skip to content

Commit d51e185

Browse files
authored
[TASK-391954] Add design-first Apps template guidance (#108)
1 parent dc0d341 commit d51e185

2 files changed

Lines changed: 176 additions & 26 deletions

File tree

‎apps/agents/instructions/default/INSTRUCTIONS.md‎

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,64 @@ Apps are a private alpha. Check the installed `@notionhq/apps` exports and
44
declarations before using a capability; SDK support does not establish that a
55
provider is enabled on the server.
66

7+
## Design the App before implementation
8+
9+
First establish what the complete App should do: its outcome, source data,
10+
triggers, external services, and every Notion resource it needs. Recommend a
11+
workflow for most automations; use a sync when the goal is to mirror an external
12+
collection into a Notion database. An App may contain both.
13+
14+
Before proposing the design, read only enough of this guidance and the
15+
top-level descriptions of the relevant capability skills (workflow, sync,
16+
connections, and Notion as Code) to describe concrete options for open
17+
decisions. Do not read full skill instructions, generated declarations
18+
(`*.generated.d.ts`), full provider API surfaces, or other implementation
19+
details until the user agrees on a direction. Verify those details against the
20+
selected option during implementation.
21+
22+
Present the proposed design concisely and get the user's agreement before
23+
implementing. Always include an App home page that explains what the App does
24+
and links to all of its Notion resources. The proposal should include:
25+
26+
- Every Notion resource the App will create, including the home page, databases,
27+
other pages, and custom agents; state each resource's purpose and which
28+
capabilities use it.
29+
- Every sync, including its external source, destination database, and
30+
synchronization behavior.
31+
- Every workflow, including its trigger, main actions, resources it reads or
32+
changes, and external connections.
33+
- Open decisions and required access.
34+
35+
Adapt the format to the App. For example:
36+
37+
### Example App design
38+
39+
**Outcome:** Bring support tickets into Notion and escalate urgent tickets to
40+
the support team.
41+
42+
**Notion resources**
43+
44+
| Kind | Name | Purpose | Used by |
45+
| ------------ | ----------------- | --------------------------------------------------- | -------------------------------- |
46+
| Page | Support app home | Explain the App and link to its resources | Team members |
47+
| Database | Support tickets | Store synchronized tickets and triage status | Ticket sync, escalation workflow |
48+
| Page | Support dashboard | Give the team an operational home and database view | Team members |
49+
| Custom agent | Ticket triage | Classify urgency and summarize a ticket | Escalation workflow |
50+
51+
**Syncs and workflows**
52+
53+
| Kind | Name | Source or trigger | Behavior | Dependencies |
54+
| -------- | ---------------------- | --------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------- |
55+
| Sync | Ticket sync | Support-system tickets | Upsert by stable external ID | Support-system connection, Support tickets database |
56+
| Workflow | Escalate urgent ticket | Support tickets page created or updated | Run triage, update status, and notify support channel | Ticket triage agent, Support tickets database, messaging connection |
57+
58+
**Open questions:** Which support system and messaging channel should the App use?
59+
60+
Ask the user to confirm or revise the design. Do not begin implementation
61+
until they agree. If implementation reveals a material resource or capability
62+
not covered by the agreed design, update the proposal and confirm the change
63+
before adding it.
64+
765
## SDK imports
866

967
Import the creation helpers you use directly from the package root:
@@ -28,25 +86,36 @@ Check that the installed SDK supports these exports before building.
2886

2987
## Capability layout
3088

89+
After the user agrees on the design, compare it with the complete scaffold.
90+
Remove template workflows, syncs, custom blocks, Notion resource declarations,
91+
sample assets, and supporting code that the App does not need. Do not leave
92+
example or placeholder capabilities in discovered capability directories: the
93+
build can include and deploy them. Preserve shared configuration and
94+
infrastructure required by the selected capabilities.
95+
3196
Each direct TypeScript file in these directories default-exports a declaration.
3297
Its filename supplies the capability key. Put capability-specific helpers in
3398
`src/workflows/lib/` (or the matching capability directory's `lib/`) and shared
3499
helpers in `src/lib/`. Discovery only reads direct children, so these helpers
35100
are not treated as capabilities.
36101

37-
| Directory | Declaration | Guidance |
38-
| ------------------- | ------------------ | --------------------------------------- |
39-
| `src/workflows/` | `workflow(...)` | `.agents/skills/workflow/SKILL.md` |
40-
| `src/syncs/` | `sync(...)` | `.agents/skills/sync/SKILL.md` |
41-
| `src/customBlocks/` | `customBlock(...)` | `.agents/skills/custom-blocks/SKILL.md` |
102+
The App template's `.agents/skills/` files point to the full SDK skills
103+
installed under `./node_modules/@notionhq/apps/skills/`. For every area you
104+
implement, follow the template pointer and read the corresponding installed
105+
SDK skill listed in this table. If the installed SDK skill is missing, install
106+
the App's dependencies; if it remains missing, update `@notionhq/apps` to a
107+
release that includes it. Do not continue without the full SDK guidance.
42108

43-
Read the matching skill before implementing a capability. Workflows that use
44-
connections also need `.agents/skills/connections/SKILL.md`.
109+
| Area | Where used | Template pointer | Full SDK skill |
110+
| -------------- | ------------------------------------------------------------ | ---------------------------------------- | ------------------------------------------------------------ |
111+
| Workflow | `src/workflows/` | `.agents/skills/workflow/SKILL.md` | `node_modules/@notionhq/apps/skills/workflow/SKILL.md` |
112+
| Connections | Workflow provider clients and triggers | `.agents/skills/connections/SKILL.md` | `node_modules/@notionhq/apps/skills/connections/SKILL.md` |
113+
| Database sync | `src/syncs/` | `.agents/skills/sync/SKILL.md` | `node_modules/@notionhq/apps/skills/sync/SKILL.md` |
114+
| Custom blocks | `src/customBlocks/` | `.agents/skills/custom-blocks/SKILL.md` | `node_modules/@notionhq/apps/skills/custom-blocks/SKILL.md` |
115+
| Notion as Code | Resources declared in modules imported by workflows or syncs | `.agents/skills/notion-as-code/SKILL.md` | `node_modules/@notionhq/apps/skills/notion-as-code/SKILL.md` |
45116

46-
For resources declared with the App, read
47-
`.agents/skills/notion-as-code/SKILL.md`. Notion as Code declarations belong in
48-
modules imported by workflows or syncs; they are not a separate discovered
49-
capability directory. Syncs can use their declared data source handles.
117+
Notion as Code declarations are not a separate discovered capability
118+
directory. Syncs can use their declared data source handles.
50119

51120
Prefer Notion as Code over other methods for equivalent supported resource
52121
setup. Use another method when the user explicitly requests it, an existing
@@ -73,5 +142,11 @@ Building does not verify server availability, published connection setup, or
73142
browser interactions. State separately which live checks actually ran.
74143

75144
For a requested deployment, enable `ntn experiments enable apps`, authenticate,
76-
and use `ntn apps deploy --name <name>` on the first deployment; omit `--name`
77-
for updates. Read the installed CLI help for other commands.
145+
and use `ntn apps deploy --json` with any required arguments. On the first
146+
deployment, pass `--name <name>`; omit `--name` for updates. Use the JSON fields
147+
`worker_url`, `setup_url`, and `is_update` in the handoff. For a first
148+
deployment (`is_update` is false), show the `setup_url` and tell the user to
149+
open it to finish setup. For an update (`is_update` is true), show both URLs
150+
with clear labels: `worker_url` opens the deployed App and `setup_url` revisits
151+
onboarding. Use the URLs returned by the CLI; do not construct or guess them.
152+
Read the installed CLI help for other commands.

‎apps/templates/apps-default/.agents/INSTRUCTIONS.md‎

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,64 @@ Apps are a private alpha. Check the installed `@notionhq/apps` exports and
44
declarations before using a capability; SDK support does not establish that a
55
provider is enabled on the server.
66

7+
## Design the App before implementation
8+
9+
First establish what the complete App should do: its outcome, source data,
10+
triggers, external services, and every Notion resource it needs. Recommend a
11+
workflow for most automations; use a sync when the goal is to mirror an external
12+
collection into a Notion database. An App may contain both.
13+
14+
Before proposing the design, read only enough of this guidance and the
15+
top-level descriptions of the relevant capability skills (workflow, sync,
16+
connections, and Notion as Code) to describe concrete options for open
17+
decisions. Do not read full skill instructions, generated declarations
18+
(`*.generated.d.ts`), full provider API surfaces, or other implementation
19+
details until the user agrees on a direction. Verify those details against the
20+
selected option during implementation.
21+
22+
Present the proposed design concisely and get the user's agreement before
23+
implementing. Always include an App home page that explains what the App does
24+
and links to all of its Notion resources. The proposal should include:
25+
26+
- Every Notion resource the App will create, including the home page, databases,
27+
other pages, and custom agents; state each resource's purpose and which
28+
capabilities use it.
29+
- Every sync, including its external source, destination database, and
30+
synchronization behavior.
31+
- Every workflow, including its trigger, main actions, resources it reads or
32+
changes, and external connections.
33+
- Open decisions and required access.
34+
35+
Adapt the format to the App. For example:
36+
37+
### Example App design
38+
39+
**Outcome:** Bring support tickets into Notion and escalate urgent tickets to
40+
the support team.
41+
42+
**Notion resources**
43+
44+
| Kind | Name | Purpose | Used by |
45+
| ------------ | ----------------- | --------------------------------------------------- | -------------------------------- |
46+
| Page | Support app home | Explain the App and link to its resources | Team members |
47+
| Database | Support tickets | Store synchronized tickets and triage status | Ticket sync, escalation workflow |
48+
| Page | Support dashboard | Give the team an operational home and database view | Team members |
49+
| Custom agent | Ticket triage | Classify urgency and summarize a ticket | Escalation workflow |
50+
51+
**Syncs and workflows**
52+
53+
| Kind | Name | Source or trigger | Behavior | Dependencies |
54+
| -------- | ---------------------- | --------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------- |
55+
| Sync | Ticket sync | Support-system tickets | Upsert by stable external ID | Support-system connection, Support tickets database |
56+
| Workflow | Escalate urgent ticket | Support tickets page created or updated | Run triage, update status, and notify support channel | Ticket triage agent, Support tickets database, messaging connection |
57+
58+
**Open questions:** Which support system and messaging channel should the App use?
59+
60+
Ask the user to confirm or revise the design. Do not begin implementation
61+
until they agree. If implementation reveals a material resource or capability
62+
not covered by the agreed design, update the proposal and confirm the change
63+
before adding it.
64+
765
## SDK imports
866

967
Import the creation helpers you use directly from the package root:
@@ -28,25 +86,36 @@ Check that the installed SDK supports these exports before building.
2886

2987
## Capability layout
3088

89+
After the user agrees on the design, compare it with the complete scaffold.
90+
Remove template workflows, syncs, custom blocks, Notion resource declarations,
91+
sample assets, and supporting code that the App does not need. Do not leave
92+
example or placeholder capabilities in discovered capability directories: the
93+
build can include and deploy them. Preserve shared configuration and
94+
infrastructure required by the selected capabilities.
95+
3196
Each direct TypeScript file in these directories default-exports a declaration.
3297
Its filename supplies the capability key. Put capability-specific helpers in
3398
`src/workflows/lib/` (or the matching capability directory's `lib/`) and shared
3499
helpers in `src/lib/`. Discovery only reads direct children, so these helpers
35100
are not treated as capabilities.
36101

37-
| Directory | Declaration | Guidance |
38-
| ------------------- | ------------------ | --------------------------------------- |
39-
| `src/workflows/` | `workflow(...)` | `.agents/skills/workflow/SKILL.md` |
40-
| `src/syncs/` | `sync(...)` | `.agents/skills/sync/SKILL.md` |
41-
| `src/customBlocks/` | `customBlock(...)` | `.agents/skills/custom-blocks/SKILL.md` |
102+
The App template's `.agents/skills/` files point to the full SDK skills
103+
installed under `./node_modules/@notionhq/apps/skills/`. For every area you
104+
implement, follow the template pointer and read the corresponding installed
105+
SDK skill listed in this table. If the installed SDK skill is missing, install
106+
the App's dependencies; if it remains missing, update `@notionhq/apps` to a
107+
release that includes it. Do not continue without the full SDK guidance.
42108

43-
Read the matching skill before implementing a capability. Workflows that use
44-
connections also need `.agents/skills/connections/SKILL.md`.
109+
| Area | Where used | Template pointer | Full SDK skill |
110+
| -------------- | ------------------------------------------------------------ | ---------------------------------------- | ------------------------------------------------------------ |
111+
| Workflow | `src/workflows/` | `.agents/skills/workflow/SKILL.md` | `node_modules/@notionhq/apps/skills/workflow/SKILL.md` |
112+
| Connections | Workflow provider clients and triggers | `.agents/skills/connections/SKILL.md` | `node_modules/@notionhq/apps/skills/connections/SKILL.md` |
113+
| Database sync | `src/syncs/` | `.agents/skills/sync/SKILL.md` | `node_modules/@notionhq/apps/skills/sync/SKILL.md` |
114+
| Custom blocks | `src/customBlocks/` | `.agents/skills/custom-blocks/SKILL.md` | `node_modules/@notionhq/apps/skills/custom-blocks/SKILL.md` |
115+
| Notion as Code | Resources declared in modules imported by workflows or syncs | `.agents/skills/notion-as-code/SKILL.md` | `node_modules/@notionhq/apps/skills/notion-as-code/SKILL.md` |
45116

46-
For resources declared with the App, read
47-
`.agents/skills/notion-as-code/SKILL.md`. Notion as Code declarations belong in
48-
modules imported by workflows or syncs; they are not a separate discovered
49-
capability directory. Syncs can use their declared data source handles.
117+
Notion as Code declarations are not a separate discovered capability
118+
directory. Syncs can use their declared data source handles.
50119

51120
Prefer Notion as Code over other methods for equivalent supported resource
52121
setup. Use another method when the user explicitly requests it, an existing
@@ -73,5 +142,11 @@ Building does not verify server availability, published connection setup, or
73142
browser interactions. State separately which live checks actually ran.
74143

75144
For a requested deployment, enable `ntn experiments enable apps`, authenticate,
76-
and use `ntn apps deploy --name <name>` on the first deployment; omit `--name`
77-
for updates. Read the installed CLI help for other commands.
145+
and use `ntn apps deploy --json` with any required arguments. On the first
146+
deployment, pass `--name <name>`; omit `--name` for updates. Use the JSON fields
147+
`worker_url`, `setup_url`, and `is_update` in the handoff. For a first
148+
deployment (`is_update` is false), show the `setup_url` and tell the user to
149+
open it to finish setup. For an update (`is_update` is true), show both URLs
150+
with clear labels: `worker_url` opens the deployed App and `setup_url` revisits
151+
onboarding. Use the URLs returned by the CLI; do not construct or guess them.
152+
Read the installed CLI help for other commands.

0 commit comments

Comments
 (0)