Skip to content

Commit 61bba2f

Browse files
committed
kpd: add example prompts for claude code
To help developers embrace claude code give examples and gradings of what Claude Code did. We can update with commit IDS and URLs later. Generated-by: Claude AI Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 3432147 commit 61bba2f

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

CLAUDE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5+
For example prompts and case studies showing successful AI-assisted development patterns, see [PROMPTS.md](PROMPTS.md).
6+
57
## Project Overview
68

79
Kernel Patches Daemon (KPD) is a Python service that connects Patchwork with GitHub repositories for automated CI testing. It watches Patchwork for new patch series, creates GitHub pull requests, and syncs CI results back to Patchwork.
@@ -121,3 +123,30 @@ docker pull ghcr.io/kernel-patches/kernel-patches-daemon:latest
121123
- Tests must pass
122124
- Code must be formatted with black
123125
- PRs should target `main` branch
126+
- AI-generated code should include attribution tags:
127+
- `🤖 Generated with [Claude Code](https://claude.ai/code)`
128+
- `Co-Authored-By: Claude <[email protected]>`
129+
130+
## AI-Assisted Development Guidelines
131+
132+
### Effective Prompting Strategies
133+
134+
1. **Provide context**: Include relevant configuration files, error messages, and system information
135+
2. **Be specific**: Describe exact symptoms, reproduction steps, and expected behavior
136+
3. **Request systematic approaches**: Ask for diagnostic tools and step-by-step debugging
137+
4. **Include testing requirements**: Specify how the solution should be tested and validated
138+
139+
### Common Development Patterns
140+
141+
- **Debugging workflow**: Implement diagnostic tools (like `--dry-run-list-candidates-only`) before attempting fixes
142+
- **Configuration issues**: Check type consistency between config files and API responses
143+
- **Lei-based patchwork**: Be aware of kernel.org's subsystem-specific patchwork instances and their characteristics
144+
- **Documentation updates**: Always update README.md, CONFIG.md, and CLAUDE.md when making significant changes
145+
146+
### Example Success Patterns
147+
148+
See [PROMPTS.md](PROMPTS.md) for detailed case studies, including:
149+
- Debugging lei-based patchwork instance compatibility
150+
- Adding new debugging features
151+
- Fixing type mismatch bugs in API integration
152+
- Improving configuration handling for different deployment scenarios

PROMPTS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# KPD Claude Code Prompts
2+
3+
This document provides example prompts and case studies for using Claude Code
4+
with the Kernel Patches Daemon (KPD) project. It serves as a guide for both
5+
human developers and AI agents to understand how to effectively extend and
6+
debug KPD functionality.
7+
8+
For general guidance on using Claude Code with this project, see [CLAUDE.md](CLAUDE.md).
9+
10+
## Debugging and Bug Fixing
11+
12+
### Lei-based Patchwork Instance Support
13+
14+
**Prompt:**
15+
```
16+
Now let's try to fix a bug we could not figure out. The patch titled
17+
"firmware_loader: prevent integer overflow in firmware_loading_timeout()" is
18+
available for testing on patchwork for the Linux firmware loader. You can run
19+
kpd for the firmware loader by running the command poetry run python -m
20+
kernel_patches_daemon --config /home/mcgrof/configs/firmware/kpd.json
21+
--label-color /home/mcgrof/shared/labels.json you will see that this just loops
22+
and just does not find any candidate patches. The new Linux firmware loader
23+
patchwork instance is a new one, it was configured by kernel.org admins to help
24+
developers who want to work on subsystems but who's patches go to a mailing
25+
list where too many patches go to linux linux-fsdevel, and so the kernel.org
26+
admins have provided lei based patchwork instances so to limit the scope of
27+
patches that go into patchwork. The Linux firmware loader is an example
28+
subsystem which then has a patchwork instance which behind the scenes uses lei.
29+
For some reason we can't get kpd to detect candidate patches. Your goal is to
30+
figure out why and fix this on kpd. However if you run the command I gave you
31+
you would have to use CTRL-C to terminate the run. Instead let's first extend
32+
kpd with a run time option to let us do a dry run, in that all we do is run
33+
once and output the candidate list of patches that we have identified as
34+
candidates. Let's call this --dry-run-list-candidates-only so that you can test
35+
this later in your second commit.
36+
```
37+
38+
**AI:** Claude Code (Sonnet 4)
39+
**Result:** Successfully debugged and fixed lei-based patchwork instance support
40+
**Grading:** 95%
41+
42+
**Notes:**
43+
- **Systematic debugging approach**: Claude Code first implemented a diagnostic tool (`--dry-run-list-candidates-only`) before attempting fixes
44+
- **Root cause analysis**: Identified the core issue was a type mismatch in patch filtering (string "423" vs integer 423 for project IDs)
45+
- **Configuration insights**: Discovered that the 7-day lookback period was too short for kernel patches, recommending 14-21 days
46+
- **Lei-based patchwork understanding**: Gained insights into kernel.org's new lei-based patchwork instances and their characteristics
47+
- **Documentation improvements**: Enhanced README.md, CONFIG.md, and CLAUDE.md with new debugging guidance
48+
49+
**Technical Details:**
50+
- **Bug location**: `kernel_patches_daemon/patchwork.py:383` in `_is_patch_matching()` method
51+
- **Fix**: Changed `patch[prop_name]["id"] != expected_value` to `patch[prop_name]["id"] != int(expected_value)`
52+
- **Impact**: Enabled KPD to work with all lei-based patchwork instances deployed by kernel.org
53+
54+
**Learning opportunities:**
55+
- Type consistency in API interactions is critical for lei-based systems
56+
- Diagnostic tooling significantly speeds up debugging complex integration issues
57+
- Configuration defaults may need adjustment for different deployment scenarios

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,37 @@ $ docker-compose build
110110
$ docker-compose up
111111
```
112112

113+
## AI-Assisted Development
114+
115+
KPD embraces AI-assisted development to accelerate feature development and debugging. The project provides comprehensive guidance for using generative AI tools effectively:
116+
117+
- **[CLAUDE.md](CLAUDE.md)**: Guidelines for using Claude Code with this repository
118+
- **[PROMPTS.md](PROMPTS.md)**: Example prompts and case studies showing successful AI-assisted development patterns
119+
120+
### Getting Started with Claude Code
121+
122+
Claude Code can help with debugging complex issues, adding new features, and understanding the codebase. Here are some effective prompting strategies:
123+
124+
**For debugging:**
125+
```
126+
I'm having trouble with KPD not detecting patches from [patchwork instance].
127+
Here's my configuration: [paste config]. When I run the dry-run command,
128+
I see [describe output]. Can you help debug this issue?
129+
```
130+
131+
**For feature development:**
132+
```
133+
I want to add [feature description] to KPD. The feature should [describe requirements].
134+
Looking at the existing codebase, what's the best approach to implement this?
135+
```
136+
137+
**For code understanding:**
138+
```
139+
Can you explain how KPD's patch synchronization works? I'm particularly interested
140+
in [specific aspect] and how it interacts with [related component].
141+
```
142+
143+
See [PROMPTS.md](PROMPTS.md) for detailed examples and successful development patterns.
144+
113145
## CONTRIBUTING
114146
See the [CONTRIBUTING](CONTRIBUTING.md) file for how to help out.

0 commit comments

Comments
 (0)