Use AI to comprehend complex codebases [AI Skills Series - Week One] #167385
Replies: 7 comments 1 reply
-
Exciting way to contribute. No purchase necessary, is that with the exception of a GitHub Pro account? |
Beta Was this translation helpful? Give feedback.
-
Wonderful, and I'd be quite happy to use GitHub Copilot, but sweat and
cognitive equity are all I can spare at the moment, unless anyone wants to
sponsor me. I look forward to tackling what I can tackle, with the tools I
have available though. Thank you Lili.
…On Thu, Jul 31, 2025 at 2:59 PM Lili ***@***.***> wrote:
@AndrewVoirol <https://github.com/AndrewVoirol> nope you can use any AI
tools that work for you! Naturally, we have the most resources on using
GitHub Copilot, but there are plenty of options and this challenge is tool
agnostic.
—
Reply to this email directly, view it on GitHub
<#167385 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BDWJ23ZZYLVQKYGM2HH2ZKD3LJRRJAVCNFSM6AAAAACCI5OLNKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGOJVGEYDGMQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
AI Skills Series - Week One SubmissionPrompt Used
Copilot Output
ChatGPT Output
Gemini Output
Insights
Prompt Suggestions
Submitted by: |
Beta Was this translation helpful? Give feedback.
-
Function: Prompt
I decided to feed the same prompt into three different models to see how they differ. ResponsesCopilot (GPT-4.1)Certainly! Here’s an overview of the function OverviewThe
Inputs:
Output:
How It Works (Step-by-step)
Example 1: Filling Gaps in Daily DataSuppose you want to chart the number of signups per day for a week, but you only have data for 3 days: $rawData = [
['date' => '2025-07-28', 'count' => 10],
['date' => '2025-07-30', 'count' => 7],
['date' => '2025-07-31', 'count' => 8],
];
// Assume $this->unit is set to 'd' (day), and the date range is 2025-07-28 to 2025-08-03 Result: [
0 => 10, // 2025-07-28
1 => 0, // 2025-07-29 (no data, so 0)
2 => 7, // 2025-07-30
3 => 8, // 2025-07-31
4 => 0, // 2025-08-01
5 => 0, // 2025-08-02
6 => 0, // 2025-08-03
] Example 2: Averaging Data Within a Time UnitSuppose you have multiple values for each week, and you want to average them: $rawData = [
['date' => '2025-07-28', 'data' => 10],
['date' => '2025-07-29', 'data' => 14],
['date' => '2025-08-03', 'data' => 6],
];
// $this->unit is 'W' (week), date range covers two weeks: 2025-07-28 to 2025-08-10
// $countAverage = true
Result: [
0 => 10, // average of values in first week
1 => 0, // no data for second week
] Example 3: Monthly Data with Gaps$rawData = [
['date' => '2025-06-15', 'count' => 20],
['date' => '2025-08-01', 'count' => 5],
];
// $this->unit = 'm' (month), covering June to August Result: [
0 => 20, // June
1 => 0, // July (no data)
2 => 5, // August
] Key Takeaways
If you have a specific dataset or time unit in mind, I can walk you through how the output would look! Maybe a bit more verbose. Solid examples. Didn't seem to emphasize special case handling. Claude Sonnet 4I'll provide a comprehensive overview of the `completeTimeData` function with practical examples.Function PurposeThe Core Functionality1. Gap FillingEnsures no missing time periods in your chart data. 2. Data AggregationCombines multiple data points within the same time interval. 3. Date NormalizationHandles timezone conversions and date formatting consistently. Detailed ExamplesExample 1: Daily Website Visits (Basic Gap Filling)Scenario: You want to chart daily website visits from July 28-31, 2025, but only have data for 3 days. // Raw data from database
$rawData = [
['date' => '2025-07-28', 'count' => 150],
['date' => '2025-07-30', 'count' => 89],
['date' => '2025-07-31', 'count' => 203]
];
// Settings: daily intervals, date range July 28-31
// $this->unit = 'd', $this->dateFrom = '2025-07-28', $this->dateTo = '2025-07-31' Output: [
0 => 150, // July 28
1 => 0, // July 29 (missing - filled with 0)
2 => 89, // July 30
3 => 203 // July 31
] Chart Result: A smooth line chart showing visits with a clear dip on July 29. Example 2: Email Opens with AveragingScenario: Multiple email campaigns sent per week, you want weekly averages. // Raw data: multiple email opens per week
$rawData = [
['date' => '2025-07-28', 'data' => 45], // Monday
['date' => '2025-07-29', 'data' => 67], // Tuesday
['date' => '2025-07-30', 'data' => 23], // Wednesday
['date' => '2025-08-04', 'data' => 89], // Next Monday
['date' => '2025-08-05', 'data' => 34], // Next Tuesday
];
// Settings: weekly intervals with averaging
// $this->unit = 'W', $countAverage = true Processing:
Output: [
0 => 45.0, // Week 1 average
1 => 61.5 // Week 2 average
] Example 3: Monthly Sales DataScenario: Quarterly sales report with some missing months. // Raw sales data
$rawData = [
['date' => '2025-04-15', 'count' => 12500], // April
['date' => '2025-04-28', 'count' => 8300], // April (another sale)
['date' => '2025-06-10', 'count' => 15700], // June (May missing)
];
// Settings: monthly intervals, Q2 2025
// $this->unit = 'm', covering April-June 2025 Processing:
Output: [
0 => 20800, // April (combined)
1 => 0, // May (missing)
2 => 15700 // June
] Example 4: Year-over-Year ComparisonScenario: Annual revenue data with gaps. $rawData = [
['date' => '2023-01-01', 'count' => 450000],
['date' => '2025-01-01', 'count' => 620000],
// 2024 missing
];
// Settings: yearly intervals, 2023-2025
// $this->unit = 'Y' Output: [
0 => 450000, // 2023
1 => 0, // 2024 (missing year)
2 => 620000 // 2025
] Special Handling FeaturesWeek Number Parsing// The function handles special week format "2025 31" (year + week number)
$rawData = [
['date' => '2025 31', 'count' => 100] // Week 31 of 2025
];
// Converts to proper date format automatically Timezone Management// Time-based data (hours/minutes) uses UTC from database
// Date-only data respects local timezone settings
// Prevents data from appearing in wrong time slots Real-World Use Cases
Key Benefits
The function essentially transforms sparse, irregular database results into the regular, complete time series that visualization libraries expect. Seems less verbose than GPT. For example, it didn't include much about the intputs and outputs. It did give good examples and covered the special case handling. Gemini 2.5 ProOf course. Let's break down the `completeTimeData` function with a focus on the problems it solves and why it's so important for creating accurate charts.The Big Picture: From Messy Data to Clean ChartsThink of this function as a data pre-processor. Its main job is to take raw, often incomplete time-based data from your database and transform it into a perfect, "chart-ready" sequence. Charting libraries like Chart.js need a complete, uninterrupted series of data points to draw a line or bar chart correctly. If you have data for Monday and Wednesday but not Tuesday, you can't just skip Tuesday. The function fixes this by adding a Two Main Jobs of the Function1. Filling in the GapsThis is its most critical role. Real-world data is almost never perfect; there will always be gaps. Problem: You're charting new user signups per day, but no one signed up on Wednesday. Your raw data looks like this: // Raw data from your database
$rawData = [
['date' => '2025-07-28', 'count' => 12], // Monday
['date' => '2025-07-29', 'count' => 8], // Tuesday
// No data for Wednesday, 2025-07-30
['date' => '2025-07-31', 'count' => 15], // Thursday
]; If you tried to plot this directly, your chart would incorrectly jump from Tuesday to Thursday, distorting the timeline. Solution: The Resulting [
0 => 12, // Monday's count
1 => 8, // Tuesday's count
2 => 0, // Wednesday is filled with 0
3 => 15 // Thursday's count
] This clean array can now be used to generate a perfect chart that accurately shows a dip to zero on Wednesday. 2. Aggregating Data (Summing or Averaging)Sometimes you have multiple data points within a single time period (e.g., multiple sales in one day) and you want to represent them as a single value. Problem: You want to chart the average score per week from a game. Your raw data has multiple scores each week. // Raw data of scores
$rawData = [
// --- Week 1 ---
['date' => '2025-08-04', 'data' => 100],
['date' => '2025-08-05', 'data' => 150],
// --- Week 2 ---
['date' => '2025-08-11', 'data' => 200],
['date' => '2025-08-13', 'data' => 250],
['date' => '2025-08-14', 'data' => 300],
]; Solution: By setting
Resulting [
0 => 125, // Average score for Week 1
1 => 250 // Average score for Week 2
] If Summary of What It Does
In short, Really great big picture overview. Very good at explaining why this function is important. |
Beta Was this translation helpful? Give feedback.
-
This week, I looked into the isomorphic-git repo and picked the readObject() function because it seemed pretty dense at first glance. I wanted to understand what exactly it was doing under the hood, so I used an AI tool to walk me through it. The explanation helped break down the logic—how it reads different Git object types, decompresses the data, and parses it based on the type. I tested the function with a small example to read a commit object, and it worked, which confirmed I actually understood what it was doing. I also tried another AI tool just to compare, and while both were helpful, one gave a bit more context than the other. If anyone else is trying this, I’d suggest picking a function that deals with async operations—it really shows how useful AI can be for understanding Promise-heavy code. Overall, it was a solid way to get familiar with a real-world codebase without feeling totally lost. |
Beta Was this translation helpful? Give feedback.
-
Function: Prompt
I have used the GitHub Copilot Models for responses and used the same prompts for responses. ResponsesClaude Sonnet 3.5I'll explain this code in simple, beginner-friendly terms! This file contains code for cloning (making a copy of) a Git repository, similar to when you run
Here's a real-world analogy: Imagine you're making a copy of an important document folder:
The code has error handling (like a safety net) - if something goes wrong during any of these steps, it cleans up after itself by removing the incomplete copy. Let me call the semantic search to find more context about how this is used: This code is a function that creates a copy (clone) of a Git repository, similar to when you use the
Here's a simple example of how it might be used: await git.clone({
fs,
http,
dir: '/my-project',
url: 'https://github.com/some-user/some-repo',
singleBranch: true,
depth: 1 // Only get the latest version
}) Think of it like downloading a project from GitHub, but with extra options to control exactly how you want to download it. It's similar to downloading a zip file of a project, but it keeps all the Git-related information so you can track changes, update the code later, and work with different versions of the code. If anything goes wrong during the process (like if your internet connection fails), the code will clean up after itself by removing any partially downloaded files, which helps prevent having broken or incomplete repositories on your computer. Explanations are provided with steps but repetitive and lengthy. Example is not up to the mark. GPT 4.1Absolutely! Here’s a very simple, beginner-friendly explanation of what’s happening in the file `src/commands/clone.js` from the isomorphic-git project: What is this file for?This file contains a function called What happens step-by-step?Let’s break down what the code does in simple language:
Real-life analogyImagine you want to copy a recipe book from a friend:
In summaryThis code automates the process of copying a Git project from somewhere else to your own computer. It does all the setup, downloading, and organizing for you—and if anything breaks, it tidies up so you don’t have a mess! Explanations are clear and provided with concise step. Real life analogy is clear. The example could be enhanced if references to the functions could be provided for easier understanding. o3-miniHere's a beginner-friendly explanation of the code in the file: The _clone function is designed to copy a Git repository (like when you run git clone in your terminal). It does several things in a step-by-step process:
Here’s a simplified analogy to help understand the process:
Below is an example showing the main steps in simplified code: // Step 1: Initialize a new Git repository (create necessary files)
await _init({ fs, gitdir });
// Step 2: Set up the connection to the remote repository.
await _addRemote({ fs, gitdir, remote, url, force: false });
// Step 3: (Optional) Store proxy configuration if provided.
if (corsProxy) {
const config = await GitConfigManager.get({ fs, gitdir });
await config.set(`http.corsProxy`, corsProxy);
await GitConfigManager.save({ fs, gitdir, config });
}
// Step 4: Download (fetch) the repository data from the remote.
const { defaultBranch, fetchHead } = await _fetch({
fs,
cache,
http,
onProgress,
onMessage,
onAuth,
onAuthSuccess,
onAuthFailure,
gitdir,
ref,
remote,
corsProxy,
depth,
since,
exclude,
relative,
singleBranch,
headers,
tags: !noTags,
});
// If nothing is fetched, exit early.
if (fetchHead === null) return;
// Pick which branch to work with.
ref = ref || defaultBranch;
ref = ref.replace('refs/heads/', '');
// Step 5: Format the files so that you can use them (checkout).
await _checkout({
fs,
cache,
onProgress,
onPostCheckout,
dir,
gitdir,
ref,
remote,
noCheckout,
nonBlocking,
batchSize,
}); And finally, if there is any error during any of these steps, the function performs cleanup by removing the partially created repository: catch (err) {
await fs
.rmdir(gitdir, { recursive: true, maxRetries: 10 })
.catch(() => undefined);
throw err;
} In summary, this code automates the process of copying a repository by setting up a local space, connecting to the remote source, downloading the content, organizing it, and ensuring that if something goes wrong, it cleans up after itself. Explanations are short. Real life example wasn't good, it took the context from the previous response. AnalysisOut of the three models, GPT 4.1 provided a more clear response compared to o3-mini and Claude Sonnet 3.5. Prompt Suggestions
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Welcome to part one of our AI Skills Series. This week we’ll be working together to break down complicated code by using AI to help understand it. As a reminder, those who participate will be entered to win one of 10 GitHub Shop vouchers.
Challenge
Pick one of the repos below:
Next:
Share:
Resources & Tools
*No Purchase Necessary. Open only to Github community members 18+. Game ends 8/21/25. For details, see Official Rules.
Beta Was this translation helpful? Give feedback.
All reactions