Skip to content

Commit 7857be4

Browse files
Merge pull request #2 from dexhorthy/improve-explaining-code-visuals
Improve explaining code visuals
2 parents 0884fcc + 38515f0 commit 7857be4

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

‎skills/explaining-code/SKILL.md‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,93 @@ queued ──→ running ──→ done
102102

103103
Keep labels concrete. Place a visual next to the text it supports. Include only the calls, files,
104104
props, states, and boundaries needed to answer the question.
105+
106+
Use one view or several, but rarely all of them. Each view must add information rather than repeat
107+
the prose.
108+
109+
## Other useful views
110+
111+
Keep structural views narrow and concrete. A call tree should show runtime order and nesting, not
112+
every function on the stack:
113+
114+
```text
115+
submitForm
116+
createSession
117+
persistPrompt
118+
launchAgent
119+
navigateToSession
120+
```
121+
122+
Use a component tree to show UI ownership. Add only the state, hooks, files, and package boundaries
123+
that explain where behavior lives:
124+
125+
```tsx
126+
<SessionPage> (apps/example/src/routes/session.tsx)
127+
useSessionEvents()
128+
<SessionToolbar>
129+
<RunSkillButton> (packages/ui)
130+
```
131+
132+
Use a shallow file tree to show responsibility or the shape of a broad refactor:
133+
134+
```text
135+
src/
136+
├── commands/ # parses user actions
137+
├── sessions/ # owns session state
138+
└── transport/ # sends API requests
139+
```
140+
141+
A `diff` block does not need to be a literal source diff. Match its shape to the view under
142+
discussion so the reader can see the behavioral or structural change without translating edited
143+
lines back into the system.
144+
145+
For a call tree or call stack change:
146+
147+
```diff
148+
submitForm
149+
createSession
150+
persistPrompt
151+
+ expandSkillMention
152+
launchAgent
153+
- navigateToSession
154+
+ navigateToSession
155+
+ subscribeToEvents
156+
```
157+
158+
For a component change:
159+
160+
```diff
161+
<SessionPage>
162+
useSessionEvents()
163+
<SessionToolbar>
164+
+ <RunSkillButton />
165+
<SessionTimeline>
166+
+ <SkillResultCard />
167+
```
168+
169+
For a file layout change:
170+
171+
```diff
172+
src/
173+
├── commands/
174+
+│ └── show-me.ts # expands the slash command
175+
├── sessions/
176+
-└── transport.ts
177+
+└── transport/
178+
+ ├── client.ts
179+
+ └── stream.ts
180+
```
181+
182+
For a state or control-flow change:
183+
184+
```diff
185+
on(save)
186+
- write content
187+
+ if content is unchanged
188+
+ return cached result
189+
+ write new content
190+
+ invalidate cache
191+
```
192+
193+
Show the whole block instead when most of it is new, omitted context would hide ownership or order,
194+
or the user needs a copyable target shape.

0 commit comments

Comments
 (0)