Implémenter une nouvelle méthode

VérifiéPrudence

Implémente une nouvelle méthode dans TorchJD en s'appuyant sur les recherches antérieures et en respectant les conventions établies.

Spar Skills Guide Bot
DeveloppementAvancé
27/07/2026
Claude Code
#multi-objective-optimization#torchjd#code-generation#api-conventions#research-papers

Recommandé pour

Synthèse automatique

Transforme un scalaire ou un agrégateur déjà étudié en une implémentation complète dans TorchJD, en ajoutant la classe, la documentation, les tests et l'entrée de changelog selon les conventions du dépôt.

Points forts

  • Impose de réconcilier les équations de l'article avec les implémentations officielles et tierces avant d'écrire du code (minimisation vs maximisation, normalisation, arguments ignorés).
  • Délègue les détails de structure à des références par type (scalarizers.md / aggregators.md) pour garder le contexte ciblé.
  • Refuse explicitement de deviner les aspects non standard de l'interface (état interne, tampons d'historique, paramètres entraînables) et demande les résultats de recherche à l'utilisateur.
  • S'appuie sur la sortie préalable de la skill research-method et sur les issues de suivi, donc l'implémentation part d'informations déjà validées.

Limites

  • Suppose que la méthode figure déjà dans l'issue de suivi et que les résultats de recherche sont disponibles ; la skill ne fonctionne pas seule.
  • Fortement couplée à la structure et aux conventions du dépôt TorchJD, donc peu réutilisable sur un autre projet.
  • Le SKILL.md fourni s'interrompt en pleine phrase et ne contient pas lui-même les conventions de code, renvoyées à des références externes.
Quand l'utiliser

Quand un contributeur dispose d'une ligne de recherche validée dans les issues de suivi TorchJD et veut produire les fichiers d'implémentation réels.

Quand l'éviter

Quand la méthode n'a pas encore été étudiée ou n'est pas listée dans l'issue de suivi — il faut d'abord lancer research-method.

Analyse de sécurité

Prudence
Score qualité85/100

The skill is a legitimate contributor workflow for adding a method to TorchJD: it reads tracking issues, compares paper vs reference implementations, edits repo files, and runs tests. There are no destructive, exfiltrating, or obfuscated instructions (no curl|sh, rm -rf, secret handling, or safety-disabling). However, it directs network fetches of external/untrusted content and command execution without a declared tool scope or pinned commands, so it is best classified as caution rather than safe.

Points d'attention
  • •No allowed-tools declared, so the skill's instruction to fetch remote URLs (GitHub issues, external 'claude.ai share' write-ups) and to run tests/lint/docs builds is not bounded by any declared tool scope.
  • •Step 1 directs the agent to fetch and trust external content (tracking issues, third-party research write-ups, paper links). This is a plausible indirect prompt-injection surface if any linked content is attacker-controlled.
  • •Steps 6 instruct running commands (unit tests with -W error, lint, docs build/doctest) without pinning exact commands in the visible text; execution is delegated to referenced files not shown, so blast radius can't be fully assessed.
  • •Step 5/3 mention adapting code from third-party repositories and adding license headers/NOTICES — legitimate, but implies copying external code into the repo, which warrants review of provenance.
Comment cette analyse est faite

Exemples

Implement a scalarizer
/implement-method stch (Smooth Tchebycheff Scalarization for Multi-Objective Optimization)
Implement an aggregator
Implement the UPGrad aggregator in TorchJD using the row from tracking issue #665, and reconcile the paper's equations with the official implementation before writing the class, docs and tests.
Recover research first
I want to add a new aggregator to TorchJD but I don't have the research write-up yet — can you check issue #665 and tell me what's missing before implementing?

name: implement-method description: Implements a new method (scalarizer or aggregator) in TorchJD, starting from the research produced by the research-method skill and following the established file-by-file conventions. Use when a contributor wants to add the actual implementation of a scalarizer or aggregator that has already been investigated and listed in the tracking issues.

Implement new method

This skill implements a new method by recovering its research, comparing the paper against the existing implementations, settling the non-standard parts of its interface, and producing the full set of TorchJD files (class, docs, tests, changelog) that match the established conventions.

It is the companion of the research-method skill: that one investigates a method and records a row in a tracking issue; this one turns that row into a merged implementation.

For agents: invoke as /implement-method method-name (paper-name) (e.g. /implement-method stch (Smooth Tchebycheff Scalarization for Multi-objective Optimization)). If no method name is provided, ask the user for the name of the method and the title of the paper.

For humans: follow the numbered steps below to guide your development.


Instructions

Step 1: Recover the research context

Determine whether the method should be a scalarizer or an aggregator, then read everything the research-method skill already found about it:

  • Scalarizers are tracked in https://github.com/SimplexLab/TorchJD/issues/667, aggregators in https://github.com/SimplexLab/TorchJD/issues/665. Fetch the relevant issue and find the row for this method. Read every column:
    • Ref — the paper (open it; you will need the exact equations / algorithm).
    • Stateful — whether and how the method holds state.
    • Existing implementations — links to the official repo (if any) and the best-known third-party ones (LibMTL, libmoon, pymoo, ...), ideally with the exact file(s) and line(s).
    • Special Remarks — may link to a full research write-up (e.g. a claude.ai share produced by research-method). Read it if present.
  • The most valuable inputs are the non-standard interface aspects uncovered during research: statefulness, trainable parameters, randomness, warm-up / history buffers, statistics beyond the forward values (e.g. per-task losses for an aggregator), and preconditions. If these are not fully captured in the issue, ask the user to share the research-method findings before continuing. Do not guess them.

If the method is not in the tracking issue yet, run research-method first.

Step 2: Load the implementation reference for this method type

Read only the reference matching the method type, to keep context focused:

  • Scalarizer → read references/scalarizers.md.
  • Aggregator → read references/aggregators.md.

Each reference lists the exact files to create/edit and the TorchJD-specific conventions, with the closest existing methods to mirror.

Step 3: Compare the paper with the existing implementations

Always do this — it is the step we invariably end up needing. Read the relevant equations / the algorithm box in the paper, then read the official and best-known third-party implementations at the exact files/lines from the tracking row.

Reconcile any discrepancies between them. The ones that most often bite:

  • Minimization vs maximization. TorchJD minimizes losses; much MOO/evolutionary work is written for maximization, with the minimization form buried in a footnote. Find it, and check the sign of every reference / ideal-point subtraction.
  • Normalization. A direction or weight vector may be normalized (w / ‖w‖) in the code but not the paper, or vice versa.
  • Dead arguments. An impl may accept a parameter (e.g. a reference point) yet silently ignore it.
  • Droppable terms. An abs / clamp / max(0, ·) in the paper may be unnecessary under the method's preconditions (e.g. non-negative weights); drop it only with a justification.
  • Other: an extra factor, an init value, a stabilization / epsilon trick.

Decide which to follow, note why, and surface the disagreement to the user — the implementation should be faithful to a clearly-stated source, not an unexplained blend.

Step 4: Settle the interface and design decisions

Using the research findings (Step 1) and the comparison (Step 3), map each non-standard aspect onto the closest existing pattern from the reference loaded in Step 2 (statefulness, trainable parameters, an internal optimizer, a preference/reference vector, ...). Then settle, for any method type:

  • Preconditions (e.g. positivity): enforce them (raise ValueError) or only document them, and how nan/inf should propagate.
  • Which constructor arguments are required vs optional, and their defaults.

List the non-standard parts and your proposed handling, and confirm the design with the user before writing code. This is where most of the maintainer review happens, so settle it up front.

Step 5: Implement the method

Follow the file-by-file checklist in the reference loaded at Step 2. Match the style, naming, and conventions of the closest existing method. If you adapt code from a third-party repository, add the license header to the source file and an entry to NOTICES (see the reference).

Step 6: Verify

Run the checks listed in the reference (unit tests with -W error, lint, and the docs build/doctest). GPU tests require a CUDA device; if you cannot run them, provide the exact commands for the user to run on their GPU and report back the results.

Step 7: Self-review the code you produced

Before opening anything, re-read your own diff against the requirements and improve what can be improved. Check that:

  • The class follows the closest existing method's conventions (the reference's checklist): correct base class(es), forward(self, values, /) returning a 0-dim scalar, shape validation, reset() for stateful methods, a correct __repr__, and the docstring conventions (r""" only with LaTeX, :class: cross-ref, .. math:: + bullet list, a usage doctest, :param: for each argument).
  • The design decisions settled in Step 4 are actually reflected in the code, and any discrepancy between the paper and the existing implementations (Step 3) is resolved deliberately, with a comment or docstring note where it is non-obvious.
  • The tests cover the documented edge cases and contracts, not just the happy path.
  • All six files are present and consistent (class, __init__.py, .rst, toctree, test, CHANGELOG.md), plus NOTICES + a license header if you adapted code.

Apply the fixes you find, then re-run the relevant checks from Step 6.

Step 8: Open a draft PR

Create a new branch, commit, and open a draft pull request targeting main, following the repository's PR conventions (a CHANGELOG.md entry under [Unreleased] > ### Added; when asked for a PR description, output raw GitHub-flavored markdown in a fenced code block, with GitHub math syntax $...$ / $$...$$ and no em dashes). Keep it a draft so the contributor can read the code themselves before requesting maintainer review. Return the PR URL when done.


Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/implement-new-method-ms2s7d0o/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/implement-new-method-ms2s7d0o' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/implement-new-method-ms2s7d0o/download' --output '.skill-downloads/implement-new-method-ms2s7d0o/SKILL.md.part' && mv '.skill-downloads/implement-new-method-ms2s7d0o/SKILL.md.part' '.skill-downloads/implement-new-method-ms2s7d0o/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/implement-new-method-ms2s7d0o/SKILL.md' && test -s '.skill-downloads/implement-new-method-ms2s7d0o/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/implement-method' && cp -R '.skill-downloads/implement-new-method-ms2s7d0o' '.claude/skills/implement-method'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/implement-new-method-ms2s7d0o'

openskills read 'implement-new-method-ms2s7d0o'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/implement-new-method-ms2s7d0o/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires