Skip to content

Commit 64508ff

Browse files
committed
Tweak claude's instructions.
1 parent 548710c commit 64508ff

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.claude/commands/corpus-loop.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
argument-hint: [corpus_slug]
3-
description: uses Playwright MCP and the `corpus:view` dev environment to help with parsing page elements
3+
description: uses Playwright MCP and the `corpus:view` to parse page elements
44
---
55

66
- using Playwright MCP, navigate to `http://localhost:3001/corpus/$1/gitcasso`
@@ -39,4 +39,19 @@ description: uses Playwright MCP and the `corpus:view` dev environment to help w
3939

4040
If you make a change to the code of the enhancer, you can click the button with id `gitcasso-rebuild-btn`. It will trigger a rebuild of the browser extension, and then refresh the page. You'll be able to see the effects of your change in the `gitcasso-comment-spots` div described above.
4141

42-
When writing `tryToEnhance` methods, don't hedge your bets and write lots of fallback code or strings of `?.`. Have a specific piece of data you want to get, use non-null `!` assertions where necessary to be clear about getting. The data they are extracting is going to change over time, and it's easier to fix broken ones if you know exactly what used to work. If the code has lots of branching paths, it's harder to tell what it was doing.
42+
## Common extraction workflow
43+
44+
If you see `"title": "TODO_TITLE"` or similar hardcoded `TODO` values in the JSON output, this indicates the enhancer needs some kind of extraction implemented:
45+
46+
1. **Find the enhancer**: Search for the `type` value (e.g., `GH_ISSUE_ADD_COMMENT`) in `src/lib/enhancers/`
47+
2. **Implement extraction**: Replace hardcoded title with DOM extraction:
48+
```javascript
49+
const title = document.querySelector('main h1')!.textContent.replace(/\s*#\d+$/, '').trim()
50+
```
51+
4. **Test with rebuild**: Click the 🔄 button to rebuild and verify the title appears correctly in the JSON
52+
53+
## Extraction code style
54+
55+
- Don't hedge your bets and write lots of fallback code or strings of `?.`. Have a specific piece of data you want to get, use non-null `!` assertions where necessary to be clear about getting.
56+
- If a field is empty, represent it with an empty string. Don't use placeholders when extracting data.
57+
- The pages we are scraping are going to change over time, and it's easier to fix broken ones if we know exactly what used to work. If the code has lots of branching paths, it's harder to tell what it was doing.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Please refer to `CONTRIBUTING.md` and `README.md`.
1+
Refer to `CONTRIBUTING.md` for the project's architecture and useful commands.
22

33
Whenever you complete a task, if you wish some info had been provided to you ahead of time instead of figuring it out from scratch, you have permission to edit this `CLAUDE.md` to add any helpful context.

0 commit comments

Comments
 (0)