In https://lecursos.com/pt-br/articles/o-projeto-no-claude-code-claudemd-memoria-e-cada-erro-virando-regra, you set up the project: the folder, CLAUDE.md with dated rules and the reasons behind them, memory, and git. You saw how each corrected mistake becomes a written rule, and how the agent only commits a version to the history when you ask. So far, the project exists, but it has yet to work with real data.In this lesson, the project ventures into the real world. Managers rely on numbers: inflation to adjust contracts, interest rates to make investment decisions, unemployment to plan hiring. And numbers are precisely where AI can be most misleading, because a made-up number looks just like a real one (remember hallucinations, covered in https://lecursos.com/pt-br/articles/como-funciona-um-modelo-de-linguagem-tokens-contexto-alucinacao-e-o-custo-de-conversar). You will learn to research with sources, download official data series straight from the source, compare periods consistently, and check every number. The case study is a campaign of mine featuring 22 official Brazilian indicators, from 2019 to 2026.1. Research with sources1.1 The agent researches, you verifyClaude Code can search the web: find pages, read their content, and bring the information into the project. This solves the knowledge cutoff problem we discussed in https://lecursos.com/pt-br/articles/como-funciona-um-modelo-de-linguagem-tokens-contexto-alucinacao-e-o-custo-de-conversar: instead of answering "from memory," the agent looks up current data.But searching the web introduces another risk. The internet has good reporting and bad reporting, current figures and outdated ones, primary sources and copies of copies. So the first rule of this lesson is simple: every piece of information the agent brings back must include its source URL. Without a URL, it is not a fact: it is a hypothesis.1.2 Primary and secondary sourcesA primary source produces the data: IBGE for unemployment, Banco Central for the Selic rate and exchange rates, Tesouro for public finances. A secondary source reproduces it: a newspaper, a blog, a bank report. Secondary sources are great for discovering that a dataset exists and understanding the context. But the number in your report should come from the primary source.Why? Because a news story may round the figure, use a different basis for comparison ("compared with the same month a year earlier" or "compared with the previous month"?), or have been written before the data was revised. And because the story may not identify exactly which series it used, leaving you unable to reproduce the calculation.In practice, ask the agent something like this: "Find the unemployment rate for the latest quarter released. Get the figure from the official source, include the URL, and identify the table it came from. If you can only find it in news coverage, say so."1.3 Be wary of too much precision and too little sourcingThere are two warning signs. The first is a number more precise than the source provides: a "rate of 7,4382%" when the agency publishes figures to one decimal place. The second is a strong claim backed by just one weak source. When the agent brings back data like this, ask for a second source or ask it to state clearly that it could not verify the figure.In my campaign project, the source file itself records what has not been verified. One example: the Ibovespa value for 2021 carries a note saying it "was not verified in a news article." That is not a weakness in the work; it is honesty about what is known.The agent provides a quarterly unemployment rate, citing a newspaper article. What is the best next step before using the figure in a report?Answer: check the figure against the primary source (IBGE), in the table it comes from. The news story helps you find the data, but the figure in the report should come from the original source, so you can reproduce it and cite it precisely.2. Download the official series instead of copying the number2.1 Data series have codesBrazil's major statistical agencies publish data in systems that use codes. We will use two sources:SGS, Banco Central's Time Series Management System. Each series has a number. In my project, for example, series 433 is monthly IPCA inflation, 13522 is the cumulative IPCA rate over 12 months, and 432 is the Selic target rate. Banco Central provides a public API: a web address that returns the entire series in a data format based on its code.SIDRA, IBGE's Automatic Retrieval System. IBGE data is organized into numbered tables. The unemployment rate from the Continuous PNAD survey, for example, is in table 6381. SIDRA also has a public API.Do not memorize the codes. Ask the agent to find them and, again, check the official page to make sure the code really matches the series you want.2.2 Why download by codeDownloading an entire series by its code, rather than copying a number from a page, changes the nature of the work:It is exact. The number comes from the agency, with every decimal place it publishes.It is repeatable. The program that downloads the data today can do it again tomorrow, with fresh data, without you having to talk to anyone. This is the lesson from https://lecursos.com/pt-br/articles/como-funciona-um-modelo-de-linguagem-tokens-contexto-alucinacao-e-o-custo-de-conversar: AI builds it once; the code repeats the task without using tokens.It is auditable. Anyone can inspect the code, see which series was downloaded, and check it on the agency's website.It includes the whole series. With the entire series, you can choose your basis for comparison later (December of each year, annual averages, the same quarter), rather than being stuck with the number a news story chose.2.3 The case study: montar.py --baixarFor the campaign featuring 22 indicators, Claude Code wrote a program called montar.py. When I run montar.py --baixar, it calls the Banco Central and IBGE APIs, downloads each series by its code, and saves everything to a data file. Another program uses that file to generate the carousel images, the PDF, and the videos.Not everything has an API. Indicators without a ready-made series available through an API went into a separate file, with the source URL for each year. In all, the 22 series came from Banco Central, IBGE, ANP, B3, INPE, Tesouro, Ministério do Desenvolvimento Social, and Fórum Brasileiro de Segurança Pública. Every indicator includes its source name, and the source appears at the bottom of each image.One detail shows how the project learns: Banco Central's daily series (such as the Selic rate and the dollar exchange rate) could not be retrieved over a long time span, because Banco Central rejects requests for many years of daily data at once. The solution, written into the program itself with a comment explaining why, was to download one year at a time. The error happened once and became code.What is the main advantage of using a program to download an SGS series by its code instead of copying a number from a news story?Answer: the number is exact, the download can be repeated, and anyone can check where it came from. You still need to know what the series measures; and a well-designed program never invents data: when something is missing, it should flag it.3. Compare on the same basis3.1 The problem with cherry-pickingWith a whole series at your disposal, it is easy to "prove" almost anything. Want to show that inflation rose? Compare a low month with a high one. Want to show that employment improved? Compare the end of the year, when retailers hire, with the beginning, when they lay people off. The choice of starting and ending points can determine the conclusion before you even look at the data.In the campaign, which compared two periods of government (2019 to 2022 and 2022 to 2026) ahead of the 2026 runoff election, that risk was obvious. Any figure would invite accusations of cherry-picking. That is why the project's README has a section with a title that says it all: rules "so no one can say it is cherry-picking." Notice that the aim here is not to debate who governed better; it is the method, which can be used to compare any two management records: two managers, two branches, or before and after a new system.3.2 The rules of the methodThese were the rules written into the project:The same criteria for both periods. An end-to-end comparison: the beginning and end of each period, calculated in the same way.A threshold for "unchanged." A small change is neither an improvement nor a deterioration. For percentage-based series, the result is "unchanged" when the change is less than 0,15 percentage points; for the others, when it is less than 1,5% of the value.Monthly series: December of each year. Always the same month, to avoid choosing whichever month suits the argument. For 2026, the latest month published, identified in the image.PNAD: always the same quarter. Unemployment, employment, and income use the June–August quarter every year, to avoid mixing seasonal effects.Values in reais adjusted for IPCA inflation. An amount in reais from 2019 cannot be compared directly with one from 2026: inflation has changed its purchasing power. Monetary values were converted into today's reais.The direction is stated. Each indicator specifies whether "lower is better" (unemployment, inflation) or "higher is better" (international reserves, life expectancy). That way, no one can reverse the interpretation halfway through.Projections shown with dashed lines. Anything in 2026 that is still a projection or an approved budget allocation, rather than an actual result, appears as a dashed line on the chart.No conclusions about how to vote. The material presents the numbers and leaves the decision to the reader.3.3 The threshold in practiceLet us apply the threshold using some example numbers. Please note: the following figures are fictional, provided only to practice applying the rule.An unemployment rate fell from 9,3% to 9,2%. The change is 9,3 minus 9,2 = 0,1 percentage points. Since 0,1 is less than 0,15, the verdict is unchanged. If it had fallen from 9,3% to 9,0%, the change would be 0,3 percentage points, above the threshold, and the verdict would be an improvement (for unemployment, lower is better).Now take a series that is not a percentage, such as reserves in billions of dollars: it rose from 350 to 354. The change is 4, and 4 ÷ 350 ≈ 1,14% of the value. Since 1,14% is less than 1,5%, this is also unchanged. If it rose to 360, the change would be 10 ÷ 350 ≈ 2,86%, above the threshold.And for the inflation adjustment: imagine a price of R$ 4,00 in a given year, with cumulative inflation of 40% since then (a fictional figure). In today's reais, that price is equivalent to 4,00 × 1,40 = R$ 5,60. It is this adjusted value that should be compared with the current price.3.4 The person decides, the code appliesNotice the division of labor. The choices were mine and are documented: which indicators to include and which to leave out. For example, the minimum wage, the Selic rate, household borrowing rates, and homelessness were left out; Bolsa Família, gasoline, Gini, and life expectancy were included. The definition of "better" was also my decision, written into the README.The code does the rest: downloads, calculates, applies the threshold, and creates the visuals. And it treats every indicator the same way. No one can "fudge" a chart without changing the code, and that change would be visible. The project's rule is explicit: do not edit the numbers by hand.In a report, the delinquency rate fell from 4,10% to 4,02%. With a threshold of 0,15 percentage points for percentage-based series, the verdict is:Answer: unchanged, because the change of 0,08 points is less than 0,15. The calculation is 4,10 minus 4,02 = 0,08. Below the threshold, the difference is treated as noise, not an improvement.4. Check every number4.1 Why check if the code downloaded it from the source?Code eliminates copying errors, but it does not eliminate every error. The agent may have chosen the wrong series code (cumulative IPCA rather than monthly IPCA), read the wrong column in the IBGE table, or reversed a series' sign (in my project, one of the Banco Central series is used with its sign reversed, as noted in the sources file). None of these mistakes shows up as an "error": each produces a plausible number.4.2 How to check without doing everything againYou do not need to check every data point in every series. A reasonable routine is:Spot-check the data. Choose two or three numbers from each series and compare them with the official website. If they match, the likelihood that the entire series is wrong drops considerably.Check the endpoints. The first and last data points are the ones used in the start-to-finish comparison. They matter most.Check for anomalies. Ask the agent to list unusual values (a large jump from one month to the next, or a negative number where there should not be one). Sometimes they reflect real events; sometimes they are reading errors.Check the calculations. Ask the agent to show the calculation behind each verdict, as we did in section 3.3, and redo one or two on a calculator.4.3 Document uncertaintyWhen a number cannot be confirmed, the honest approach is to say so. In my project, the sources file records the research carried out on 23/10/2026 and the remaining uncertainties. For homelessness, for example, there is no national series from 2019 to 2021: the value was estimated and shown as a dashed line (this indicator was left out of the final piece). The 2021 Ibovespa figure was marked as unconfirmed.This ties in with https://lecursos.com/pt-br/articles/o-projeto-no-claude-code-claudemd-memoria-e-cada-erro-virando-regra: documenting what is unknown prevents someone, including the agent itself, from later filling the gap with an invented number.When checking a series downloaded by the agent, which combination of checks is most efficient?Answer: check a sample, the first and last data points, and unusual values. The API guarantees the source, not that the agent chose the right series and column. The endpoints determine the comparison.5. Public data comes with responsibilities, too5.1 Legal precautionsThe campaign was designed for social media during an election period, which called for precautions documented in the project's README. Do not pay to boost posts (do not buy ads), because Article 57-C of Law 9.504/97 reserves paid promotion of election content for candidates, parties and coalitions. Do not post on election day. And do not edit the numbers manually.For managers, the broader lesson is this: publishing a number means taking responsibility for it. Before releasing an analysis, ask who could be affected, which rules apply (election, competition or data protection rules), and whether every number has a source. The agent can research the law, but the decision to publish is yours.5.2 A consistent method, without taking sidesComparing periods under different administrations is a sensitive subject, and this lesson is not intended to defend either side. The point is different: with primary sources, criteria set before looking at the results, a threshold for "unchanged", a stated direction of improvement and documented uncertainties, the discussion shifts from "who chose the numbers" to the numbers themselves. This applies to any comparison a manager makes: two branches, two suppliers, or conditions before and after a project.6. Common mistakes"If the agent found it online, it must be true." The internet contains incorrect and outdated data. Insist on the URL and check the primary source."Copying the number from a news story is faster." It is faster once. From the second time onward, downloading the series with code is faster, accurate and auditable."I'll choose the criteria after seeing the data." That is exactly how cherry-picking starts. Define the criteria (month, quarter, threshold, direction of improvement) before looking at the results, and apply them consistently."It came from the official API, so I don't need to check." The API guarantees the source, not the selection. The wrong series, the wrong column or a reversed sign can all produce plausible numbers. Spot-check the data.7. Putting it all togetherResearch with sources: every data point comes with a URL, and the number used in the report comes from the primary source, not a news story.Download with code: Banco Central's SGS and IBGE's SIDRA have numbered series and public APIs. The program downloads the data, repeats the process and leaves a clear trail.Use consistent comparison criteria: the same month, the same quarter, inflation-adjusted reais, a threshold for "unchanged" and a stated direction of improvement, all defined before looking at the results.Check every number: check samples, endpoints and unusual values, and document anything that could not be confirmed.Publishing means taking responsibility: cite sources in the footer, take legal precautions and never edit numbers manually.In the next lesson, the project will produce content: documents, presentations and videos with AI: inside the production process at the Le Cursos channel.Claude Code activity (20 minutes)1. Open Claude Code in the "ia-gestao" folder and ask: "Create a folder called dados. Write a program that uses public APIs to download three series: monthly IPCA and the Selic target rate from Banco Central's SGS, and the PNAD Contínua unemployment rate from IBGE's SIDRA, from 2019 to today. Save the raw data in the dados folder and tell me each series code and the URL used."2. Before approving, read what it plans to run. Then check each agency's official website to make sure the codes match the requested series.3. Ask: "Create a chart with the three series, one below the other, with the source listed in the footer, and save it as graficos.png."4. Choose two numbers (for example, IPCA for December 2022 and unemployment for the most recent quarter) and check them on the Banco Central and IBGE websites. Do they match? If not, work with the agent to find out why (wrong series? wrong period?).5. Ask: "Compare December 2022 with the latest available data for each series, using a threshold of 0,15 points to classify the result as unchanged. Show the calculation."6. Ask the agent to record the project's data rules in CLAUDE.md: "numbers only from primary sources, with URLs; series downloaded with code; comparison criteria defined in advance; numbers never edited manually" (with today's date and the reason). Make a commit.Class discussion exerciseA retail chain wants to know whether its new regional manager, who took over a year ago, has improved sales. As a group, establish comparison rules "so no one can call it cherry-picking": which months to compare, how to account for inflation, what threshold to use for "unchanged", which direction represents improvement for each indicator, and how to handle stores that opened or closed during the period. Which decisions belong to the person, and which can the code apply?Exercises1) To use the unemployment rate in a report, the most appropriate source is:A) a social media post with a rounded figure.B) an answer from a language model without internet access.C) a blog that discussed the data last week.D) the PNAD Contínua table in IBGE's SIDRA, cited with its code and URL.E) the recollection of a colleague who saw the figure in the newspaper.2) In the campaign featuring 22 indicators, PNAD data was always compared for the same quarter (June to August) because:A) it was the only quarter with available data.B) using the same quarter avoids confusing seasonal employment patterns with real change.C) the June-to-August quarter always shows lower unemployment.D) election law requires that quarter.E) IBGE only publishes data for that quarter.3) An amount in 2019 reais was adjusted to today's reais using a cumulative inflation rate of 30% (hypothetical). If the original amount was R$ 50,00, the adjusted amount is:A) R$ 50,00.B) R$ 53,00.C) R$ 65,00.D) R$ 80,00.E) R$ 150,00.4) A reserves series rose from 300 to 304 (in billions). With a threshold of 1,5% of the value for "unchanged", the verdict is:A) unchanged, because 4 ÷ 300 ≈ 1,33%, below 1,5%.B) an improvement, because the number rose.C) a deterioration, because the change was small.D) unchanged, because any change below 10 counts as unchanged.E) impossible to say without the chart.5) (True or false) "Downloading a series with code from an official API reduces copying errors, but does not remove the need to check whether the agent selected the correct series, column and period."( ) True ( ) False6) (True or false) "To avoid accusations of cherry-picking, the best approach is to look at the results first and then choose the comparison criteria that make the analysis clearest."( ) True ( ) FalseAnswer key1) D — The number used in the report comes from the primary source, with the table code and URL, so anyone can reproduce the work.2) B — Employment varies throughout the year. Always comparing the same quarter separates real change from seasonal effects.3) C — 50,00 × 1,30 = 65,00. The adjustment multiplies the amount by one plus cumulative inflation.4) A — The change is 304 minus 300 = 4; 4 ÷ 300 ≈ 1,33% of the value, below the 1,5% threshold. The verdict is therefore unchanged.5) True — The API guarantees the source. The agent chooses the code, column and period, and a mistake there produces a plausible number. Spot-checking is still necessary.6) False — It is the other way around: the criteria are defined before looking at the results and applied consistently. Choosing afterward is the very definition of cherry-picking.
Reactions
0
0 Comments
Be the first to comment
Nothing here yet.