Skip to content

Commit 5606726

Browse files
committed
Ignore old events and stuff
1 parent 983e321 commit 5606726

File tree

7 files changed

+831
-6
lines changed

7 files changed

+831
-6
lines changed

.vale.ini

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,46 @@ BasedOnStyles =
4242
[sites/docs/src/content/api_reference/**/*.mdx]
4343
BasedOnStyles =
4444

45-
# Ignore events directory - must be at end
46-
[sites/main-site/src/content/events/**/*.md]
45+
# Ignore events from previous years only (2024 and before) - must be at end
46+
[sites/main-site/src/content/events/2018/**/*.md]
4747
BasedOnStyles =
4848

49-
[sites/main-site/src/content/events/**/*.mdx]
49+
[sites/main-site/src/content/events/2019/**/*.md]
50+
BasedOnStyles =
51+
52+
[sites/main-site/src/content/events/2020/**/*.md]
53+
BasedOnStyles =
54+
55+
[sites/main-site/src/content/events/2021/**/*.md]
56+
BasedOnStyles =
57+
58+
[sites/main-site/src/content/events/2022/**/*.md]
59+
BasedOnStyles =
60+
61+
[sites/main-site/src/content/events/2023/**/*.md]
62+
BasedOnStyles =
63+
64+
[sites/main-site/src/content/events/2024/**/*.md]
65+
BasedOnStyles =
66+
67+
[sites/main-site/src/content/events/2018/**/*.mdx]
68+
BasedOnStyles =
69+
70+
[sites/main-site/src/content/events/2019/**/*.mdx]
71+
BasedOnStyles =
72+
73+
[sites/main-site/src/content/events/2020/**/*.mdx]
74+
BasedOnStyles =
75+
76+
[sites/main-site/src/content/events/2021/**/*.mdx]
77+
BasedOnStyles =
78+
79+
[sites/main-site/src/content/events/2022/**/*.mdx]
80+
BasedOnStyles =
81+
82+
[sites/main-site/src/content/events/2023/**/*.mdx]
83+
BasedOnStyles =
84+
85+
[sites/main-site/src/content/events/2024/**/*.mdx]
5086
BasedOnStyles =
5187

hooks/README.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Claude Code Hooks for nf-core Website
2+
3+
This directory contains Claude Code hooks that automatically format and lint files when Claude modifies them, providing real-time feedback on prose quality using Python for robust JSON processing and integration.
4+
5+
## Available Hooks
6+
7+
### 🔧 `post-tool.py`
8+
9+
**Triggers**: After Claude uses Write, Edit, or MultiEdit tools
10+
**Implementation**: Python 3 with structured JSON input/output
11+
**Actions**:
12+
13+
- Reads Claude Code's structured JSON input via stdin
14+
- Runs `prettier --write` on modified files for consistent formatting
15+
- Runs `vale` prose linting on markdown/MDX files
16+
- Provides immediate feedback on writing quality to Claude via JSON output
17+
- Respects existing `.vale.ini` configuration
18+
- Returns `additionalContext` to Claude when prose issues are found
19+
20+
### 📋 `user-prompt-submit.py`
21+
22+
**Triggers**: When user submits documentation-related prompts
23+
**Implementation**: Python 3 with smart prompt detection
24+
**Actions**:
25+
26+
- Reads user prompt from Claude Code's JSON input
27+
- Checks recently modified documentation files (last 10 minutes)
28+
- Runs Vale prose quality checks on recent files
29+
- Only activates for documentation-related prompts (auto-detects keywords)
30+
- Provides context to Claude via JSON output about documentation quality
31+
- Adds guidance on nf-core documentation standards
32+
33+
### 🛠️ `utils.py`
34+
35+
**Purpose**: Shared Python utilities for all hooks
36+
**Functions**:
37+
38+
- JSON input/output handling for Claude Code integration
39+
- Tool availability checking (prettier, vale)
40+
- File type filtering and validation
41+
- Robust formatting and linting with error handling
42+
- Recent file detection and processing
43+
- Claude Code hook output formatting
44+
45+
## Setup Instructions
46+
47+
### 1. Configure Claude Code Settings
48+
49+
The hooks are automatically configured in `.claude/settings.local.json`:
50+
51+
```json
52+
{
53+
"hooks": {
54+
"PostToolUse": [
55+
{
56+
"matcher": "Write|Edit|MultiEdit",
57+
"hooks": [
58+
{
59+
"type": "command",
60+
"command": "\"$CLAUDE_PROJECT_DIR\"/hooks/post-tool.py"
61+
}
62+
]
63+
}
64+
],
65+
"UserPromptSubmit": [
66+
{
67+
"hooks": [
68+
{
69+
"type": "command",
70+
"command": "\"$CLAUDE_PROJECT_DIR\"/hooks/user-prompt-submit.py"
71+
}
72+
]
73+
}
74+
]
75+
}
76+
}
77+
```
78+
79+
### 2. Verify Dependencies
80+
81+
The hooks work best when these tools are installed:
82+
83+
- **Python 3** - Hook implementation language (system default)
84+
- **prettier** - Code formatting (`npm install -g prettier`)
85+
- **vale** - Prose linting (`brew install vale`)
86+
87+
### 3. Test the Setup
88+
89+
```bash
90+
# Test post-tool hook with proper Claude Code JSON input
91+
echo '{"tool_name":"Write","tool_input":{"file_path":"test.md"}}' | ./hooks/post-tool.py
92+
93+
# Test user-prompt-submit hook with documentation prompt
94+
echo '{"prompt":"Help me write documentation"}' | ./hooks/user-prompt-submit.py
95+
96+
# Test user-prompt-submit hook with non-documentation prompt (should exit silently)
97+
echo '{"prompt":"What is the weather?"}' | ./hooks/user-prompt-submit.py
98+
```
99+
100+
## How It Works
101+
102+
### Post-Tool Hook Flow
103+
104+
1. **Claude modifies files** using Write/Edit/MultiEdit
105+
2. **Hook triggers** automatically after tool execution
106+
3. **Prettier formats** the modified files for consistency
107+
4. **Vale checks prose** quality and terminology
108+
5. **Feedback provided** to Claude about writing quality
109+
110+
### User-Prompt Hook Flow
111+
112+
1. **User submits prompt** containing documentation keywords
113+
2. **Hook scans** for recently modified documentation files
114+
3. **Vale checks** prose quality of recent changes
115+
4. **Summary provided** before Claude responds
116+
117+
### Smart Filtering
118+
119+
- **File types**: Only processes `.md`, `.mdx`, `.js`, `.ts`, `.astro`, `.yml`, `.yaml`
120+
- **Vale linting**: Only on markdown/MDX files
121+
- **Respects `.vale.ini`**: Ignores API reference docs and old events
122+
- **Performance**: Only processes changed files
123+
124+
## Benefits
125+
126+
### For Claude
127+
128+
-**Real-time feedback** on prose quality
129+
-**Learning opportunity** from Vale suggestions
130+
-**Consistent formatting** via prettier
131+
-**Terminology awareness** (nf-core specific terms)
132+
133+
### For Contributors
134+
135+
-**Automatic formatting** of Claude-generated content
136+
-**Prose quality assurance** built into the workflow
137+
-**Consistent style** across all documentation
138+
-**No additional setup** required
139+
140+
### For Project
141+
142+
-**Maintains high documentation standards**
143+
-**Reduces review overhead** for maintainers
144+
-**Ensures consistent terminology** usage
145+
-**Professional documentation** quality
146+
147+
## Example Output
148+
149+
When Claude modifies a file with prose issues:
150+
151+
```
152+
🤖 Claude Code Hook: Post-Tool Formatting & Linting
153+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
154+
155+
🔧 Tool used: Edit
156+
📁 Processing files:
157+
→ docs/new-guide.md
158+
🎨 Formatting docs/new-guide.md with prettier...
159+
✅ Formatted successfully
160+
📝 Checking prose quality with Vale...
161+
📊 Vale found prose suggestions:
162+
7:8 error Use 'nf-core' instead of 'nf_core'
163+
9:5 error Use 'Bytesize' instead of 'bytesize'
164+
165+
💡 These suggestions help improve documentation clarity and consistency.
166+
```
167+
168+
## Troubleshooting
169+
170+
### Hook Not Running
171+
172+
- Verify hooks are configured in Claude Code settings
173+
- Check that hook files are executable (`chmod +x hooks/*.sh`)
174+
- Ensure you're in the correct directory
175+
176+
### Missing Tools
177+
178+
- Install prettier: `npm install -g prettier`
179+
- Install Vale: `brew install vale`
180+
- Hooks will gracefully skip missing tools
181+
182+
### Vale Issues
183+
184+
- Hooks respect your existing `.vale.ini` configuration
185+
- API reference docs and old events are automatically ignored
186+
- Vale suggestions are informational, not blocking
187+
188+
This system creates a seamless feedback loop where Claude learns from its writing and continuously improves documentation quality! 🚀

0 commit comments

Comments
 (0)