Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .claude/commands/issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
description: Fetch details of a GitHub issue, create a dedicated local branch, implement the changes, verify, and commit.
argument-hint: "<issue-number> e.g. 42"
---

Work on a GitHub issue for dlight-client. The issue number to address is: **$ARGUMENTS**

Follow these steps exactly, stopping and reporting to the user if any step fails.

## 1. Validate inputs

- If no issue number was provided in `$ARGUMENTS`, stop and ask the user: "Please specify the issue number you want to work on, e.g., `/issue 42`."
- Ensure `$ARGUMENTS` is a valid number. If not, stop and inform the user.

## 2. Fetch issue details

Run the following command to retrieve the issue details:
```bash
gh issue view "$ARGUMENTS"
```

Read and analyze the output to understand:
- The problem statement.
- The proposed changes.
- The acceptance criteria.

If the command fails (e.g. because of network issues or if the issue does not exist), stop and report to the user.

## 3. Create a branch

Extract the title from the issue output and derive a slug:
- Lowercase, alphanumeric, and hyphens only.
- Format: `issue-$ARGUMENTS-<slug>` (max ~50 characters total).
- Example: Issue 42 "pre-commit config for ruff" → `issue-42-ruff-pre-commit`

Check out a new branch:
```bash
git checkout -b <branch-name>
```

## 4. Implement changes

Locate the target files in the repository. Implement the changes requested in the issue description, ensuring:
- You adhere to PEP 8 coding style and existing project conventions.
- You do not introduce unrelated modifications.
- If there are new public methods or parameters, you update the documentation in `docs/` as required by `CLAUDE.md`.

## 5. Verify the changes

Run the test suite and verify formatting/linting before committing:
```bash
# Run unit tests
python -m unittest discover tests/

# Run ruff check and format check
ruff check .
ruff format --check .
```

If any check fails, resolve the issues before moving forward.

## 6. Commit the changes

Stage only the modified and newly created files:
```bash
git add <modified-files>
```
Do not stage helper scripts or build artifacts.

Compose a conventional commit message that references and closes the issue:
- Format: `<type>(<scope>): <summary> (closes #$ARGUMENTS)`
- Example: `chore(ci): add pre-commit config for ruff (closes #42)`

Commit the staged changes:
```bash
git commit -m "<commit-message>"
```

## 7. Confirm

Tell the user:
- What issue was worked on (number and title).
- The name of the branch created.
- The list of files modified.
- The commit message and hash.
- Remind them that they can run `/commit` to push the branch and prepare a pull request.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ updates:
schedule:
interval: "weekly"
open-pull-requests-limit: 5

- package-ecosystem: "pre-commit"
directory: "/"
schedule:
interval: "weekly"

7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
Comment on lines +1 to +7

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To ensure general repository hygiene beyond Python files, it is highly recommended to include standard pre-commit hooks such as trailing-whitespace, end-of-file-fixer, and check-yaml. This helps maintain consistent formatting across all file types (e.g., Markdown, YAML, JSON).

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.5.0
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ git clone https://github.com/irishsmurf/dlight-client.git
cd dlight-client
python -m venv .venv && source .venv/bin/activate
pip install -e .
pip install pytest pytest-asyncio flake8 ruff
pip install pytest pytest-asyncio flake8 ruff pre-commit

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since Ruff is being introduced as the primary linter and formatter (and is configured in the pre-commit hooks), flake8 is now redundant. Removing it from the installation instructions reduces dependency bloat and avoids potential conflicts between different linting tools.

Suggested change
pip install pytest pytest-asyncio flake8 ruff pre-commit
pip install pytest pytest-asyncio ruff pre-commit
References
  1. Avoid redundant linting and formatting tools to prevent conflicting rules and reduce dependency overhead.

pre-commit install
python -m pytest tests/
```

Expand Down Expand Up @@ -54,6 +55,15 @@ ruff check dlightclient/
- Type hints on all public methods
- Comments only when the *why* is non-obvious

### Pre-commit Hooks

To ensure consistent formatting and linting, please set up the pre-commit hooks:

```bash
pip install pre-commit
pre-commit install
```

## Commit conventions

[Conventional Commits](https://www.conventionalcommits.org/): `feat:`, `fix:`, `docs:`, `chore:`, `test:`, `refactor:`, `perf:`. One logical change per commit.
Expand Down
Loading
Loading