Skip to content

Add Copilot guidance on reusing existing library functions#28

Merged
oyve merged 2 commits intodevfrom
copilot/improve-code-reuse
Oct 28, 2025
Merged

Add Copilot guidance on reusing existing library functions#28
oyve merged 2 commits intodevfrom
copilot/improve-code-reuse

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

Adds technical instructions to .github/copilot-instructions.md emphasizing code reuse to prevent duplication of existing formulas and utilities.

Changes

New "Code Reuse and Avoiding Duplication" section

  • Added as first subsection in Coding Guidelines for visibility (marked CRITICAL)
  • Lists all reusable functions by category: temperature conversions, humidity calculations, pressure/altitude calculations, utilities, and constants
  • Provides discovery methods: file search keywords, module indexes, similar formula imports
  • Includes ❌ BAD vs ✅ GOOD examples:
// ❌ BAD - Reimplementing saturation vapor pressure
export function badHumidityCalc(temperature: number): number {
  const svp = 611.2 * Math.exp((17.62 * (temperature - 273.15)) / (243.12 + (temperature - 273.15)));
  // Don't reimplement existing formulas!
}

// ✅ GOOD - Reusing existing saturation vapor pressure
import { saturationVaporPressure } from './humidity';

export function goodHumidityCalc(temperature: number): number {
  const svp = saturationVaporPressure(temperature);
  // ... rest of calculation
}

Updated "Common Mistakes to Avoid"

  • Elevated "Code Duplication" to Merge dev into main #1 priority
  • Added explicit warning against reimplementing temperature conversions

Enhanced "New Formula Checklist"

  • Added step 0: "Check for Existing Code" before implementation begins
  • Added checklist item to verify reuse of existing library functions

Note

Function names use "Celcius" spelling (e.g., kelvinToCelcius()) matching the existing codebase API, not standard "Celsius" spelling.

Original prompt

Make a technical note for Copilot that it should use existing formulas and functions in the code libary as much as possible in new code, to avoid duplicates.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…duplication

Co-authored-by: oyve <16225018+oyve@users.noreply.github.com>
Copilot AI changed the title [WIP] Encourage use of existing formulas and functions in new code Add Copilot guidance on reusing existing library functions Oct 28, 2025
Copilot AI requested a review from oyve October 28, 2025 15:01
@oyve oyve marked this pull request as ready for review October 28, 2025 15:24
@oyve oyve merged commit aa075df into dev Oct 28, 2025
6 checks passed
@oyve oyve deleted the copilot/improve-code-reuse branch October 28, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants