LibrePatch
Workflows

Free open source software: list licences, then fix and test

03
Licence check

List the dependencies and read each licence before you contribute

You open the folder of a project you plan to change and want to know which licences its dependencies carry before you send a contribution. The agent lists the files, reads the licence texts and writes a table of packages, versions and licences. The result is a table that you check row by row against the licence texts, and you correct what is wrong. It is a draft that helps you ask the right questions, and the project's own files stay the source of truth. Work through the 4 steps below in order, and stop at any step where something looks unclear to you.

01

Open the folder

Open the project's folder in a new chat and choose Ask first, so every change is shown to you before it is written. Check that the folder is the project you may change, and not a copy that belongs to someone else. This takes a minute. Use a new chat for each project.

02

List the files

Let list_dir and glob find the dependency files and the licence files, and read the list of results the agent shows in the chat. Open any card that looks unusual, because a card shows the full result. Nothing is edited in this step. Take your time.

03

Read the licences

Use read_file and grep to read the licence texts and the SPDX lines, and note anything you do not understand, so that you can ask the project about it. Code with no licence is, in most countries, not free to reuse. You are only reading here, not changing files.

04

Check the result

Review the CSV file and the diff, then compare each row with its licence text and run the project's tests if you changed files. Accept only what you have understood, and reject the rest. Then send the contribution yourself, as the project asks. Keep a copy of the inventory.

Example licence inventory in a CSV file

licenses.csv
package,version,licence,note
lib-a,1.0,MIT,keep notice
lib-b,2.0,BSD-3-Clause,keep notice
lib-c,1.5,Apache-2.0,keep notice
lib-d,3.0,MPL-2.0,share file changes
lib-e,1.2,GPL-3.0-only,share changes
lib-f,2.1,MIT,keep notice
lib-g,1.0,BSD-3-Clause,keep notice
lib-h,1.1,Apache-2.0,keep notice

The file lists eight example packages with invented names, their versions and their licence identifiers. Replace the rows with the real ones from your project. A short note in the last column says what to keep or share, and you check it against the licence text. The names, versions and licences here are examples only, and a real inventory has one row for each dependency.

Walkthrough: read the licences, add a header, run the tests, review

Explore the code and find the licence files

You start with list_dir to see the folder structure and glob to find LICENSE, COPYING and dependency files, and then grep searches the source files for SPDX lines. Free open source software normally states its licence in these 3 places, so the search shows what each file declares and which files declare nothing. Maintainers of an open source learning app often list the features wanted next in their issues, so read those too before you pick a task. Read, do not edit. Every result is a card you can expand, and at the end of this step you have a list of files and licences to check, which you review carefully before you move on to the next step. Save your notes in a text file so that you can return to them later.

Read the licence and the contribution rules

Now read_file opens the LICENSE file and the CONTRIBUTING file. The licence tells you what you may do with the code, and the contribution rules tell you how the project wants changes to be sent, so read both completely. Your first open source contribution is easier to accept when it follows those rules exactly, so note them down. Some contributors ask whether to share their AI coding session history in open source work; the project's policy on AI-assisted changes answers that, and it may ask you to say that a tool helped. Run the project's own tests once before you change anything, so you know the starting result. Then review your notes and write down the rules that apply to your change. Read the code of conduct too, if the project has one, because it says what behaviour is expected.

Add the header the project asks for

Some projects require a short licence header, for example an SPDX line, at the top of each new file. Only when the CONTRIBUTING file or the LICENSE says so, you use edit_file to add exactly that header to your 3 new files, and in Ask first the agent shows a diff before anything is written. Keep every existing copyright notice and never change a licence. Review the diff line by line. Then use grep to list the files that still lack the header and run the project's test command, because the exit code tells you whether the command finished without an error. If a test fails, read the output before you change anything else, and ask the project when a header rule is unclear. Use the same header line in each file.

Check the result before you send it

Finally grep shows which files lack the header, Shell runs the tests again and reports the exit code, and you read the whole diff once more. These are 3 results to compare. A source code vulnerability scanner command that you provide can also run through Shell; the agent shows its output and you decide what it means, but neither the scan nor the agent guarantees that nothing else is wrong. Write the pull request description, mention the licence you checked and the tests you ran, and send it yourself. Follow the project's rules. Reviewers may ask for changes, and you answer them the same way: a small step, a diff, a test. Wait for their answer before you change more. Thank the reviewer when they help, and keep every answer short and polite, one fix at a time.

LibrePatch for Windows

Start your first licence workflow

Download LibrePatch ↗