A TypeScript superset for SDGs-aware programming - Write sustainable code that contributes to the United Nations Sustainable Development Goals.
- π Full TypeScript Compatibility: Use existing TypeScript code seamlessly
- π SDGs Annotations: JSDoc-style syntax for expressing SDGs compliance
- π Static Analysis: AST-based carbon footprint and resource usage prediction
- β‘ Runtime Monitoring: Optional real-time resource tracking
- π οΈ Developer Tools: VSCode extension, ESLint plugin, and report generation
- π Impact Measurement: Quantify your code's environmental and social impact
npm install -g sdgscript
mkdir my-sdg-project
cd my-sdg-project
sdgscript init
npm install
/**
* @sdg Goal13 ClimateAction
* @carbonBudget 1.5kWh
* @impact environment high
* @description Efficiently process climate data
*/
async function processClimateData(data: ClimateRecord[]): Promise<ProcessedData> {
return withSDGContext({
goal: 'Goal13_ClimateAction',
carbonBudget: 1.5
}, async () => {
// Your efficient implementation here
trackResource('computation', { energy: 0.8, emissions: 400 });
return processedData;
});
}
# Generate comprehensive SDGs compliance report
sdgscript analyze src/ --format html -o sdg-report.html
# Check specific metrics
sdgscript analyze src/ --format json | jq '.summary'
// .eslintrc.json
{
"extends": ["@typescript-eslint/recommended"],
"plugins": ["@sdgscript/eslint-plugin"],
"rules": {
"@sdgscript/require-sdg-annotation": "warn",
"@sdgscript/avoid-inefficient-loops": "error",
"@sdgscript/limit-network-calls": "warn"
}
}
sdgscript/
βββ π§ packages/core/ # AST transformation & analysis engine
βββ π» packages/cli/ # Command-line tools
βββ π§ packages/eslint-plugin/ # ESLint integration
βββ β‘ packages/runtime/ # Runtime monitoring APIs
βββ π¨ packages/vscode-extension/ # VSCode language support
Goal | Focus Area | Programming Context |
---|---|---|
Goal 7 | Clean Energy | Energy-efficient algorithms, optimization |
Goal 13 | Climate Action | Carbon footprint reduction, green computing |
Goal 4 | Quality Education | Accessible technology, digital inclusion |
Goal 5 | Gender Equality | Bias detection, inclusive design |
Goal 12 | Responsible Consumption | Resource efficiency, caching strategies |
/**
* @sdg Goal13 ClimateAction
* @carbonBudget 2.0kWh
* @impact environment critical
*/
export async function analyzeGlobalTemperatureData(
sensors: SensorData[]
): Promise<ClimateInsights> {
return withSDGContext({
goal: 'Goal13_ClimateAction',
carbonBudget: 2.0,
description: 'Global temperature trend analysis for climate action'
}, async () => {
// Efficient batch processing to minimize energy consumption
const insights = await processInBatches(sensors, 100);
trackResource('climate_analysis', {
energy: 1.8,
emissions: 900, // gCOβ
dataPoints: sensors.length
});
return insights;
});
}
SDGScript automatically tracks and reports:
- π Energy Consumption: kWh estimates for code execution
- π± Carbon Emissions: COβ equivalent calculations
- β‘ Performance Metrics: Algorithm efficiency analysis
- π SDGs Score: 0-100 compliance rating
- π‘ Optimization Suggestions: Actionable improvement recommendations
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
git clone https://github.com/yuis-ice/sdgscript.git
cd sdgscript
npm install
npm run build
npm test
MIT License - see LICENSE file for details.
- Built with TypeScript and ts-morph
- Inspired by the UN Sustainable Development Goals
- Carbon calculation models based on Green Software Foundation research