Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions skills/implement/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
name: implement
description: Build a detailed todo from an approved plan.md, refine it through annotation, then implement everything without stopping.
disable-model-invocation: true
---

## Hard Constraints (every phase, no exceptions)

- **`plan.md` must exist and contain `**APPROVED**`.** If `$CLAUDE_PROJECT_DIR/.claude/agents/plan.md` does not exist or has no `**APPROVED**`, stop and tell the user to run `/plan-it` first.
- **Read every relevant file in full** — not headers, not signatures, not the first few lines. Do not infer behavior from names alone.
- **Scope**: only files inside `$CLAUDE_PROJECT_DIR`.
- **Every `**note**` must be explicitly resolved** — incorporated, rejected with a reason, or escalated as a question. No note may be silently ignored.
- **During implementation**: no unnecessary comments, no JSDoc/XML doc on internal code, no `any` or unknown types in TypeScript, no `.unwrap()` without justification in Rust. Run typecheck continuously — do not introduce new type errors.

---

## Mode Detection

Check the state of `$CLAUDE_PROJECT_DIR/.claude/agents/plan.md`:

| State | Action |
|---|---|
| Does not exist or no `**APPROVED**` | Stop — tell the user to run `/plan-it` first |
| `**APPROVED**` present, no `## Implementation Todo` section | **Todo mode** — run Phase T |
| `## Implementation Todo` exists, contains `**note**` markers | **Todo revision mode** — run Phase TR |
| `## Implementation Todo` exists, contains `**APPROVED**` | **Implementation mode** — run Phase I |
| `## Implementation Todo` exists, no notes, no second approval | Tell the user: "Todo exists but is not approved. Add `**note**` annotations to revise, or add `**APPROVED**` under the todo to begin implementation." |

---

## Todo Mode — Phase T

Entered when `plan.md` is approved but has no `## Implementation Todo` section yet.

### T1 — Read the Plan

Read `plan.md` in full. Read every file listed in the Changes section in full.

### T2 — Write the Todo

Append a `## Implementation Todo` section to `plan.md`. Do not modify anything above it.

The todo must break the plan into phases and each phase into individual, atomic tasks. A task is atomic when it touches one concern in one place and can be marked complete independently.

```markdown
## Implementation Todo

> Add `**APPROVED**` below this line when the todo is ready for implementation.

### Phase 1: <name>
- [ ] <specific task — what to do and in which file>
- [ ] <specific task>

### Phase 2: <name>
- [ ] <specific task>
- [ ] Run typecheck — verify no new errors introduced

### Phase N: Verify
- [ ] Run typecheck — full clean pass
- [ ] Run lint
- [ ] Confirm all tasks above are marked complete
```

Every phase must end with a typecheck task. The final phase is always verification.

### T3 — Stop and Present

Tell the user: *"Todo written to `.claude/agents/plan.md`. Review it — add `**note**` annotations for anything to revise, or add `**APPROVED**` under the todo header when ready to implement."*

**Stop. Do not write any code.**

---

## Todo Revision Mode — Phase TR

Entered when the todo section exists and contains `**note**` markers.

**Note format:**
```
---

**note** <description>

---
```

### TR1 — Address Every Note

For each `**note**` in the todo section:
- **Incorporated** — update the affected tasks and remove the note marker
- **Rejected** — remove the note marker and add a `**note:rejected**` entry explaining why
- **Question** — ask the user before continuing if the note cannot be resolved from the plan and codebase alone

### TR2 — Rewrite the Todo Section

Rewrite only the `## Implementation Todo` section with all notes resolved. Do not touch anything above it in `plan.md`.

### TR3 — Stop and Present

List every note and its resolution. Then tell the user: *"All notes addressed. Review the updated todo — add more `**note**` annotations to continue revising, or add `**APPROVED**` to begin implementation."*

**Stop. Do not write any code.**

---

## Implementation Mode — Phase I

Entered when the todo section exists and contains `**APPROVED**`.

### I1 — Read Everything

Read `plan.md` in full. Read every file that will be changed in full before writing a single line of code.

### I2 — Implement

Work through every task in the todo, phase by phase, in order.

**For each task:**
1. Implement the change
2. Run typecheck immediately after — fix any new errors before moving on
3. Mark the task complete in `plan.md`: `- [x]`

**Do not stop between tasks.** Do not stop between phases. Complete the entire todo without pausing unless a genuine blocker is encountered (a task is impossible as written, or a new error cannot be resolved). If blocked, describe the blocker and ask — then continue with remaining tasks while waiting.

**Code quality during implementation:**
- No unnecessary comments or section dividers
- No JSDoc or XML doc on internal/private code
- TypeScript: no `any`, no implicit `unknown` — all types must be explicit and correct
- Rust: no `.unwrap()` without a documented invariant
- C#: no empty catch blocks, no `throw ex` — use `throw` to preserve stack trace
- Honor the existing code style in every file touched — match naming, formatting, and patterns already present

**TypeScript / SPFx specifics:**
- Use `.then().catch()` — never `async`/`await`
- `.catch()` must use `LoggingService.Instance.Log` if present, otherwise the project's existing logging pattern

**C# specifics:**
- Wrap `IDisposable` in `using` / `using var`
- Batch `ExecuteQuery` calls — do not scatter them
- Prefer synchronous code unless the existing code is already async

**Rust specifics:**
- Propagate errors with `?` — not `.unwrap()` in non-test code
- No `unsafe` without justification

### I3 — Final Verify

After all tasks are marked complete:
- Run typecheck — must be clean
- Run lint
- Confirm every task in the todo is marked `- [x]`

### I4 — Report

Tell the user what was implemented, phase by phase. Flag any deviations from the plan (tasks that had to be adapted) and explain why.
158 changes: 158 additions & 0 deletions skills/plan-it/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
name: plan-it
description: Read research.md and write a detailed implementation plan to plan.md. Annotation cycle with user until APPROVED. Requires research to have been run first.
argument-hint: "[what to build, change, or fix]"
disable-model-invocation: true
---

Plan the following: **$ARGUMENTS**

## Hard Constraints (every phase, no exceptions)

- **`research.md` is required.** If `$CLAUDE_PROJECT_DIR/.claude/agents/research.md` does not exist, stop immediately and tell the user to run `/research` first.
- **No code changes.** The only file you may write is `$CLAUDE_PROJECT_DIR/.claude/agents/plan.md`.
- **Read every relevant file in full** — not headers, not signatures, not the first few lines. Do not infer behavior from names alone.
- **Scope**: only files inside `$CLAUDE_PROJECT_DIR`.
- **Every `**note**` must be explicitly resolved** — incorporated, rejected with a reason, or escalated as a question. No note may be silently ignored.

---

## Mode Detection

Before doing anything else, check the state of `$CLAUDE_PROJECT_DIR/.claude/agents/plan.md`:

| State | Action |
|---|---|
| Does not exist | **Initial mode** — run Phases 1–5 |
| Exists, contains `**APPROVED**` | Stop — tell the user the plan is approved and to run `/implement` |
| Exists, contains `**note**` markers | **Revision mode** — run Phase R |
| Exists, no notes, no approval | Tell the user: "plan.md exists but has no notes and is not approved. Add `**APPROVED**` to proceed to implementation, or add `**note**` annotations for revision." |

---

## Initial Mode — Phases 1–5

### Phase 1 — Load Research

Read `$CLAUDE_PROJECT_DIR/.claude/agents/research.md` in full. Everything in the plan must be grounded in what the research established.

If the research scope does not cover the area this plan needs to change, flag it and ask the user whether to proceed with partial context or run `/research` on the missing area first.

### Phase 2 — Clarify Scope

Parse the argument:
- What is the goal?
- What is explicitly in scope?
- What is explicitly out of scope?

If the argument is ambiguous, ask before proceeding. Do not plan on assumptions.

### Phase 3 — Investigate Current State

Read every file relevant to the planned change in full. The research was broad — this reading is targeted to the specific change.

**Stack-specific things to consider:**

*TypeScript / SPFx*
- Where does this touch the webpart/extension lifecycle?
- Which PnPjs calls are involved — are they already batched?
- How does existing error handling work in the affected files?

*C# / CSOM*
- Which `ClientContext` operations are affected — will batching change?
- Is there existing async code in this area, or is it synchronous?
- What exception handling patterns are already in place?

*Rust*
- Will the change affect the `Result` type of any public functions?
- Are there ownership or lifetime constraints the change must work within?
- Does this touch any `async` code paths?

### Phase 4 — Write plan.md

Write to `$CLAUDE_PROJECT_DIR/.claude/agents/plan.md`:

```markdown
# Plan: <short title>

## Goal
<what we are building or changing, and why — grounded in research.md findings>

## Approach
<the chosen strategy and why this approach over alternatives>

## Changes

### `path/to/file.ext`
**Type**: modify / new file / delete
**What changes**: <what needs to change in this file and why — specific enough to locate, not yet line-level>

## Order of Changes
1. `file` — reason
2. `file` — depends on #1

## New Files
| File | Purpose |
|---|---|
| `path/to/new/file` | what it will contain |

*(Remove section if no new files)*

## Out of Scope
<what this plan explicitly does NOT change>

## Risks
<what could regress, edge cases, anything non-trivial>

## Open Questions
<anything unresolved — must be answered before approving>
```

### Phase 5 — Stop and Present

Summarize to the user:
- Number of files changing
- Approach in one sentence
- Any open questions

Then tell the user: *"Plan written to `.claude/agents/plan.md`. Review it — add `**note**` annotations for anything to revise, or add `**APPROVED**` when ready to move to implementation."*

**Stop. Do not proceed.**

---

## Revision Mode — Phase R

Entered when `plan.md` exists and contains `**note**` markers.

**Note format written by the user:**
```
---

**note** <description of the issue or requested change>

---
```

### R1 — Read Everything

Read `research.md` and the current `plan.md` in full. Read any project files referenced in the notes or needed to address them.

### R2 — Address Every Note

For each `**note**` marker in `plan.md`, explicitly resolve it:
- **Incorporated** — update the relevant section of the plan and remove the note marker
- **Rejected** — remove the note marker and add a `**note:rejected**` entry explaining why the change would be wrong or out of scope
- **Question** — if the note cannot be resolved without more information, ask the user before continuing

No note may remain unaddressed when writing the updated plan.

### R3 — Rewrite plan.md

Write the updated `plan.md` with all notes resolved. The plan must remain complete — do not leave gaps where notes were removed.

### R4 — Stop and Present

List every note and how it was resolved (incorporated / rejected / answered). Then tell the user: *"All notes addressed. Review the updated `.claude/agents/plan.md` — add more `**note**` annotations to continue revising, or add `**APPROVED**` when ready."*

**Stop. Do not proceed.**
Loading