Skip to content

New prompt categories#2

Open
StevenACoffman wants to merge 2 commits intoloov:mainfrom
StevenACoffman:new_categories
Open

New prompt categories#2
StevenACoffman wants to merge 2 commits intoloov:mainfrom
StevenACoffman:new_categories

Conversation

@StevenACoffman
Copy link
Copy Markdown
Contributor

@StevenACoffman StevenACoffman commented Mar 31, 2026

Hello again, I've been adding some additional categories and more prompts to try to guide my dreamlint with practices

Signed-off-by: Steve Coffman <steve@khanacademy.org>
Signed-off-by: Steve Coffman <steve@khanacademy.org>
@StevenACoffman
Copy link
Copy Markdown
Contributor Author

@egonelbre This includes PR #1 but I can separate them if you would like

@StevenACoffman StevenACoffman changed the title New categories New prompt categories Mar 31, 2026
Copy link
Copy Markdown
Member

@egonelbre egonelbre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to consider what to include and what not to include from these.

The main goals for the builtin prompts are to:

  1. be useful for all projects
  2. focus on correctness issues (mainly)
  3. be good examples how to build your own

More prompts also means that things run slower and more expensive.

It would be an interesting idea to have a way to specify different categories, e.g. "Go Conventions" or "HTTP" or "Database" related. That way we could have some more stylistic prompts without encumbering the base experience.

PS: the base prompts have definitely not been finalized, they are merely first iteration of them. So, I definitely want to improve them.


## Functions (mutually recursive group)
{{range .Functions}}
### {{.Name}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the reasons I avoided including comments is, because my gut feeling is that it might make LLM think of the wrong thing. i.e. comment contains something that the code contradicts.

There might be a better way to handle this though. e.g. cross check against docs and the func content instead of just trusting godoc/body together.


## Context Patterns

- context.Context stored as a struct field — it must be passed as an explicit function parameter
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite always the case. Sometimes contexts are used to control lifecycle for several goroutines. Alternatively, it could be passed inside a wrapper struct, which contains additional info.

and-channel design would eliminate the shared state entirely
- errgroup or fan-in channel not used to collect results from parallel goroutines — instead,
results accumulated via a shared slice with a mutex, or goroutines write directly to an
external resource rather than sending immutable values to an owner
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see all of these Design category things being necessary in some scenarios due to performance.

- time.Now() compared against another time.Now() across goroutines to determine ordering —
wall clocks drift and NTP can move time backward; use a monotonic measurement (time.Since,
time.Now().Add) for elapsed time and timeouts; use wall-clock time only for display
- time.Now(), rand, or os.Getenv called inside concurrent logic instead of injected at the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These while not ideal, I'm not sure how well this would catch issues.

@@ -0,0 +1,36 @@
You are reviewing Go code for context and authorization pattern violations.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context use issues and authorization seem very different categories to me and can be handled separately.

## Retries

- Retry loop uses time.Sleep with a fixed interval — use exponential backoff with random jitter
(base * 2^n + jitter) to avoid coordinated retry storms when many clients fail simultaneously
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also need an upper limit. Or maybe in general "use best practice exponential backoff" without specifying exactly which one.

## CRUD Conventions

FindByID / FindOne:
- Returns (nil, nil) when the entity does not exist — must return ENOTFOUND
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not that clear.


FindByID / FindOne:
- Returns (nil, nil) when the entity does not exist — must return ENOTFOUND
- Does not wrap the callee's error with an Op before returning
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was already handled somewhere else.

- Does not wrap the callee's error with an Op before returning

FindMany / List:
- Result slice declared with var (encodes as JSON null) — initialize with make([]*T, 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make([]*T) would be fine, the 0 doesn't add anything.


FindMany / List:
- Result slice declared with var (encodes as JSON null) — initialize with make([]*T, 0)
- Returns ENOTFOUND for an empty result set — an empty list is not an error
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENOTFOUND is more of a C style error name.

@egonelbre
Copy link
Copy Markdown
Member

PS: I initially had more categories 05e6e9b, but decided to trim them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants