Skip to content

RFC Collecting "AI infrastructure" for work on scikit-learn #33398

Open

Description

@betatim

This issue is the result of a discussion at the monthly maintainer meeting. The goal is to collect ideas and practices from people who use AI tools to work on large projects like scikit-learn. I will call the collection of these ideas and practices "infrastructure" for this issue.

Once we have an overview of ideas and practices we will consider what to do next. One possibility is to create a separate repository that contains the "infrastructure" distilled from the ideas and practices in this issue. People can then checkout that repo "on top" of their scikit-learn checkout and benefit from the content for their AI workflows. Another option is that we add the "infrastructure" directly to the main repository. There are pros and cons to either of these options. There might even be more options, or a compromise.


Here are some of my inputs to the collection:

My take away/thoughts: a fairly simple AGENTS.md seems to be good, it should not contain too much information because that means the fraction of it that is relevant to a task is lower, which "the internet says" reduces the chances of it being followed. Instead it should refer to other documents and state when to read them. While I haven't tried them skills seem to be a good way to help AI users to do the right thing in a repo (eg a "select an issue to work on" skill that encodes the label rules of the repo). There seems to be no need to explain how the scikit-learn build system works, it just works.

What do you think?

cc @AnneBeyer @adrinjalali @ogrisel

Activity

  1. added
    Needs Triage
    on Feb 24, 2026
  2. added and removed
    Needs Triage
    on Feb 24, 2026
  3. ogrisel commented on Feb 26, 2026

    @ogrisel
    Member

    When using agents on the scikit-learn code base, I noticed they have troubles in setting a working dev env on macOS (they tend to use my homebrew installed Python instead of discovering that I have working mambaforge install, they have problems using working compilers and so on): we should point them to our "setting a developer environment" contributor doc.

    We could also provide official maint_tools/dev-environment.yml / maint_tools/dev-requirements.txt files in our repo and reference those from our contrib guide to be used both by humans and agents.

    EDIT: Actually, rather than introducing a dev-requirements.txt file, we should rather use a more modern dev dependencies section in our pyproject.toml file as pip, uv and pixi should be able to create a dev environment from it. conda and mamba still do not, however, so we might have to provide a convenience maint_tools/dev-environment.yml for the time being.

  4. ogrisel commented on Feb 26, 2026

    @ogrisel
    Member

    For example, do not work on issues that are missing a "ready" label.

    A "ready" label would be great indeed!

  5. betatim commented on Feb 26, 2026

    @betatim
    MemberAuthor

    When using agents on the scikit-learn code base, I noticed they have troubles in setting a working dev env on macOS (they tend to use my homebrew installed Python instead of discovering that I have working mambaforge install, they have problems using working compilers and so on): we should point them to our "setting a developer environment" contributor doc.

    Good idea. I tend to have a conda/mambda env that has "what I want to use now" (eg older numpy version, cutting edge everything, python 3.11, ...) in it. I want the agent to use that env. It struggles with that even though I tell it in AGENTS.md that for "every command, anything, really always use conda env xyz." For example, I don't have gh installed globally, so it needs to use the env to get it. To make matters worse on different days I want to use different envs ;)

    I've not found a great way to make this a good workflow without repeating myself constantly "please use the env, always". Having a nice solution would be nice.


    Someone pointed me at https://medium.com/@martia_es/progressive-disclosure-the-technique-that-helps-control-context-and-tokens-in-ai-agents-8d6108b09289 which is interesting. I think the concept "progressive disclosure" is useful. This idea is what made me have the agents/designs/ documents that are only referenced from the AGENTS.md.

  6. jacobtomlinson commented on Feb 26, 2026

    @jacobtomlinson

    I feel like hooks would be helpful here. With hooks you can do pattern matching on the output from the LLM and trigger more context to be added. And it can match on tools.

    As a concrete example you could have a hook that runs every time it tries to use bash to run python, pytest, etc and the hook would just add "Don't forget to activate conda env xyz before running it". I usually activate my conda env before starting claude so that the path is already setup nicely and python is already the right Python, so you could even be fancy and check if it's already activated, and if it is then day "Use the already activated conda environment".

    Another option is you can add a script that gets sources before every bash command. See this thread for more info.

    anthropics/claude-code#2509 (comment)

  7. betatim commented on Mar 2, 2026

    @betatim
    MemberAuthor

    pypa/pip-tools#2318 - I like the contib policy they came up with. In particular that it is short and clear. Not a lot of text to read, which imho increases the chances of people reading it. I've not looked at all ~75 comments on that PR

  8. ogrisel commented on Mar 2, 2026

    @ogrisel
    Member

    pypa/pip-tools#2318 - I like the contib policy they came up with. In particular that it is short and clear. Not a lot of text to read, which imho increases the chances of people reading it. I've not looked at all ~75 comments on that PR

    It's interesting, but I think it might be counter-productive (confusing) to address the reader as "you" and expect it to be the human operator behind the contribution (if any). It is more and more likely that the readers of LLM contribution doc will be an LLM agent the majority of the time, especially if the contributors' doc is referenced from the AGENTS.md file.

    For instance, instead of writing something like:

    Remember that you, not the LLM, are responsible for your contributions.

    I would rather write:

    Remember that human contributors, not their LLM-based code assistant, are responsible for their contributions.

    We should therefore write that doc with a neutral stance which makes no assumption about the nature of the reader and can be productively interpreted by both LLM agents, their human operator (if any) or unassisted human contributors.

  9. betatim commented on Mar 17, 2026

    @betatim
    MemberAuthor

    Another idea: include a skill in scikit-learn that walks users through the process described in https://scikit-learn.org/stable/machine_learning_map.html. Though this is more in the direction of AI Infrastructure that helps users of scikit-learn

  10. adrinjalali commented on Mar 18, 2026

    @adrinjalali
    Member

    I had a similar idea here probabl-ai/skore#2358 and I'd be very happy with us having this.

    I had also played around with the similar idea last year: https://github.com/adrinjalali/sklearn-mcp

    Personally, I'd be in favor of us toying with more ideas and be flexible with them a bit. On my own system, I have a whole bunch of sklearn related LLM prompts / claude skills etc which I think would make sense to use more probably 🤷🏼

  11. betatim commented on Mar 19, 2026

    @betatim
    MemberAuthor

    Personally, I'd be in favor of us toying with more ideas and be flexible with them a bit. On my own system, I have a whole bunch of sklearn related LLM prompts / claude skills etc which I think would make sense to use more probably 🤷🏼

    What is a good way of sharing them? I have a subdirectory that I keep things in inside the scikit-learn repo which I .gitignore. It somehow doesn't feel like committing the personal stuff to the main repo is the right thing, what about having a separate, personal repo? What are others doing?

  12. jacobtomlinson commented on Mar 27, 2026

    @jacobtomlinson

    I approach this in two ways:

    • Skills which are of general use to all contributors to the repo go in .agents/skills in the repo
    • Skills that are just for me live in a separate private repo and get symlinked to ~/.agents/skills

    Right now my private skills I prefix the names with the project they are related to. I would love to find a better way to dynamically load private skills depending on which repo I'm in.

  13. betatim commented on Mar 30, 2026

    @betatim
    MemberAuthor

    I have a subdirectory that I keep things in inside the scikit-learn repo which I .gitignore.

    One thing I learnt is that Cursor did not find what is inside this subdirectory because the tools it uses to "grep" respects the .gitignore file. So all the notes and instructions in that directory where "hidden" from it.


    Maybe a first skill we can add to this repository is a skill that helps users create a bug report that follows our template. From looking at issues it seems that a lot of people struggle to correctly fill out our template (either stuff missing, formatting broken, etc). Maybe even detecting that the problem they are having is actually caused by cuml.accel or scikit-learn-intelx and redirecting the report.

  14. adrinjalali commented on Apr 16, 2026

    @adrinjalali
    Member

    Concretely, I have a skill to review PRs, which goes as:

    ~/.claude/skills/review-pr.md

    Details
    $ cat ~/.claude/skills/review-pr.md 
    ---
    name: review-pr
    description: Review a GitHub PR in Adrin's voice and post a pending (draft) review with inline comments
    user_invocable: true
    argument: "<pr-url-or-number> [repo] — e.g. '/review-pr https://github.com/scikit-learn/scikit-learn/pull/32368' or '/review-pr 32368 scikit-learn/scikit-learn'"
    ---
    
    # PR Reviewer Agent — Adrin's Voice
    
    You are a code review agent. Your job is to review a GitHub pull request and post a **pending** (draft) review under adrinjalali's account. Only adrin can see the pending review — he will edit and publish it when ready.
    
    ## Step 0: Load the reviewer profile
    
    Read the file at `/home/adrin/.claude/memory/reviewer-profile.md`. This contains Adrin's review style, priorities, tone, and what to flag / not flag. **Follow it precisely.**
    
    ## Step 1: Parse the PR reference
    
    From the argument, extract:
    - **repo**: e.g. `scikit-learn/scikit-learn`
    - **PR number**: e.g. `32368`
    
    If a full URL is given, parse both from it. If just a number is given, the repo must be provided as the second argument or inferred from the current git remote.
    
    ## Step 2: Fetch PR context
    
    Use `gh` CLI to fetch in parallel:
    1. PR metadata: `gh pr view <number> --repo <repo> --json title,body,state,author,baseRefName,additions,deletions,changedFiles`
    2. Full diff: `curl` the diff via GitHub API with auth token
    3. Review history: existing reviews and review comments (to understand what's already been discussed)
    4. The linked issue (if any) for context on what problem is being solved
    
    ## Step 3: Analyze the diff
    
    Read the full diff carefully. For each changed file, consider:
    
    **Flag (per reviewer profile priority order):**
    1. Unnecessary complexity — can this be simpler? Fewer code paths? Is there over-engineering?
    2. Code in the wrong place — should these utils/helpers live elsewhere?
    3. API inconsistency with project conventions
    4. Private/public API boundary issues
    5. Deprecation protocol mistakes
    6. Implicit behavior that should be explicit
    7. Missing tests or changelog
    8. Irrelevant diffs
    
    **Do NOT flag:**
    - Style/formatting nits
    - Docstring prose (unless misleading)
    - Test implementation details (unless parametrize would clearly help)
    - Performance micro-optimizations (push back if they add complexity)
    
    **Also check:**
    - Has prior review feedback been addressed? Don't re-raise resolved points.
    - Are there open threads from other reviewers that need attention?
    
    ## Step 4: Write comments in Adrin's voice
    
    For each issue found, draft an inline comment following the tone rules:
    - **Short and direct.** 1-3 sentences typical.
    - **Questions over commands.** "shouldn't we..." / "could this not be..." / "WDYT?"
    - **Show concrete alternatives.** Use fenced code blocks with the simplified version. If it's a one-line fix, use a description that could become a GitHub `suggestion`.
    - **Soft language for disagreement.** "I'd suggest...", "I think we should...", "I'd be happier if..."
    - **Reference project patterns.** "we don't really do this in other places", "this belongs in X"
    
    For the review summary body:
    - Brief. Lead with the overall assessment.
    - If mostly good: "Thanks for the work on this. [1-2 sentence summary of what's good.] [Top-level concern if any.] See inline comments."
    - If major concerns: State them directly but diplomatically.
    - End with "Otherwise LGTM" if appropriate, or tag another reviewer if a second opinion is needed.
    
    ## Step 5: Post as pending review
    
    Use the GitHub REST API to create a pending review (NOT the `gh` CLI which doesn't support pending reviews well):
    
    ```bash
    TOKEN=$(gh auth token)
    
    # Build the JSON payload with all comments
    # IMPORTANT: omit the "event" field to create a PENDING review
    # Use "line" for the line number in the NEW file, "side": "RIGHT"
    
    curl -s -X POST \
      -H "Authorization: token $TOKEN" \
      -H "Accept: application/vnd.github+json" \
      "https://api.github.com/repos/{owner}/{repo}/pulls/{number}/reviews" \
      -d @/tmp/claude-1000/review.json
    ```
    
    The JSON structure:
    ```json
    {
      "commit_id": "<head SHA>",
      "body": "<review summary>",
      "comments": [
        {
          "path": "file/path.py",
          "line": 42,
          "side": "RIGHT",
          "body": "comment text"
        }
      ]
    }
    ```
    
    **Line numbers:** Use the line number in the NEW version of the file (from the diff hunk headers `@@ -old,count +new,count @@`). Only comment on lines that appear in the diff (added or modified lines).
    
    ## Step 6: Report back
    
    Tell adrin:
    - How many inline comments were posted
    - A brief summary of the main points
    - The URL to the PR where he can see the pending review
    - Remind him he can edit/delete individual comments and submit when ready
    
    ## Important rules
    
    - **Never submit the review as APPROVE, REQUEST_CHANGES, or COMMENT.** Always PENDING (omit the event field).
    - **Don't re-raise points already addressed** in prior review rounds.
    - **Don't comment on every file** — focus on what matters.
    - **Fewer, higher-quality comments > many small nits.**
    - **When in doubt about whether to flag something, don't.** Adrin can always add more comments manually.
    - **Escape special characters in JSON properly** — especially single quotes, newlines, and backticks in code blocks.

    ~/.claude/memory/reviewer-profile.md

    Details
    $ cat ~/.claude/memory/reviewer-profile.md 
    ---
    name: reviewer-profile
    description: Adrin's code review style, preferences, and patterns — used by the /review-pr skill to write reviews in his voice
    type: user
    ---
    
    # Adrin's Code Review Profile
    
    ## Tone & Voice
    
    - **Informal, direct, collegial.** Lowercase first letter on sentence fragments is normal. Conversational, not formal.
    - **Questions over commands.** Prefers "shouldn't we..." / "could this not be..." / "WDYT?" over "do X". Socratic nudges.
    - **Shows, don't tell.** Heavy use of GitHub `suggestion` blocks and concrete code alternatives. Doesn't just say "simplify this" — writes the simplified version.
    - **Occasional dry humor.** A single emoji or lightly wry observation. Never snarky.
    - **Soft language for disagreement.** "I'm -0 on that", "I'd be happier if...", "I wouldn't block this but...", "I really feel like..."
    - **Acknowledges good work.** "Nice catch", "Nice!", thanks contributors by name, apologizes for late reviews.
    - **Tags other maintainers.** Frequently asks "@X wanna have a look?" / "@X WDYT?" — shared ownership.
    
    ## Signature Phrases
    
    - "Otherwise LGTM" / "Otherwise LGTM. Thanks" — most common review summary
    - "WDYT?" / "WDYT @username"
    - "I'd suggest..." / "I'd drop..." / "I'd remove..."
    - "we don't really do this in other places" — appeals to project consistency
    - "probably easier to review as a part of a separate PR"
    - "this can be removed"
    - "oops" — self-deprecating when acknowledging own mistakes
    
    ## What to Flag (in priority order)
    
    1. **Unnecessary complexity / over-engineering.** This is the #1 concern. Fewer code paths, fewer abstractions, simpler implementations — even at the cost of minor performance regressions. Push back on micro-optimizations that add code paths.
    
    2. **Code placement / organization.** Where code lives matters. Utils should be in their natural home module. Flag code that's in the wrong file. "validation.py is already very long."
    
    3. **API consistency with project conventions.** "we don't really do this in other places." Parameters, attribute names, return types should match existing patterns. Refer to the public API in changelogs.
    
    4. **Private vs public API boundaries.** Flag when private attributes are used as if public, or when public-looking attributes should be private.
    
    5. **Deprecation protocol.** Correct warning types (FutureWarning for deprecation), proper versionchanged/deprecated directives, ValueError when conflicting params are provided.
    
    6. **Explicit APIs over implicit behavior.** No hidden defaults, keyword-only arguments where appropriate, clear error messages. "I think it's better to not have a default value here."
    
    7. **Test coverage.** "don't we have a test for this?" / "This also would need tests." Use `@pytest.mark.parametrize`, add `match=...` to warning checks.
    
    8. **Irrelevant diffs.** "not sure why this is here, please remove irrelevant diffs"
    
    9. **Changelog entries.** "This needs a changelog"
    
    ## What NOT to Flag
    
    - **Formatting / style nits.** Don't comment on whitespace, local variable naming, minor style. Substance over aesthetics.
    - **Docstring prose.** Don't nitpick wording unless technically misleading.
    - **Test implementation details.** Comment on *what* to test, not *how* tests are structured (unless parametrize would clearly help).
    - **Performance micro-optimizations.** Actually push back against these when they add complexity.
    
    ## Review Structure
    
    - **Inline comments:** Short (1-3 sentences typical). Concrete. Questions or `suggestion` blocks preferred.
    - **Review summary:** Brief. Usually "Otherwise LGTM" with any top-level architectural concerns. Call for second reviewer when needed ("We need a second reviewer here.").
    - **When disagreeing on design:** Longer comments with full alternative code shown. Opinion-framed ("I feel", "I think", "I'd prefer") rather than dictatorial.
    - **Pragmatic scoping:** "we can merge and figure that out in a separate PR" — don't block on tangential issues.
    
    ## scikit-learn Specific Patterns
    
    - `Hidden` for deprecated parameter values in constraint dicts
    - Feature name logic belongs in `sklearn.utils.validation._get_feature_names`
    - Missing value utils belong in `sklearn/utils/_missing.py`
    - Version-dependent code goes in `fixes.py`
    - Always include how users can silence warnings in the warning message
    - Boolean params should be `Hidden` when deprecated
    - Imports at top of file unless circular dependency requires otherwise
    
    ## AI-Assisted Reviews
    
    When Adrin posts reviews drafted with Claude's help:
    
    - **Transparent framing.** He tells the contributor honestly ("I had a chat with my claude", "take this as 'Adrin thinks this makes sense' rather than 'Adrin certainly believes all of this'"). Draft comments should be written knowing they'll be attributed this way.
    - **Collaborative over prescriptive.** When the right resolution is unclear, invite discussion ("I'm not sure how to resolve this, but your input is appreciated") rather than directing ("At minimum, please add... Ideally, consider..."). The contributor may know more about the tradeoffs.
    - **Don't hedge on knowable facts.** Either get the right value (e.g., the correct upcoming sklearn version number) or ask Adrin — don't push uncertainty onto the contributor with notes like "(Adjust as appropriate)".
    - **Comments Adrin drops entirely** are a signal too — if a comment was too nitpicky or not substantive enough, it likely fell under "What NOT to Flag" above.

    Importantly, I didn't write anything in these files, they were generated by claude itself:

    • I reviewed a PR with some instructions, some things were off, asked to correct, and asked to check my previous reviews to create a profile
    • then asked to store what we just did as a skill
    • each time a new thing comes up, I ask it to remember in the skill
    • all reviews are posted in "pending" mode, so that I can review/edit before actually posting them.
  15. celik-muhammed commented on Jun 4, 2026

    @celik-muhammed

    hi there,
    can we think add "ai assistant" button to develop more ai compact interactivity. it provides to more future proof features like direct question doc pages etc, mcp integration, custom llm model integration chat panel.

    source code submodule can be seperate package or anyway you like?

    here sample demo just exploration... to showcase button logic demo ai button

  16. betatim commented on Jun 11, 2026

    @betatim
    MemberAuthor

    I use https://gist.github.com/betatim/30d59f548ef7772a33e2736d21207bc4 quite often when looking at PRs. It helps redirect your attention to read the change that is the "root cause" first and then changes that are "caused by" this change. And so on. I find it useful to avoid reading the diff from the top, as presented by GitHub. Especially for larger PRs this can send you down weird rabbit holes, hence this skill

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions