home / skills / kevinslin / llm / dev.add-license

dev.add-license skill

/skills/dev.add-license

This skill adds an Apache-2.0 LICENSE file to a repository, auto-filling copyright from git and updating package.json when present.

npx playbooks add skill kevinslin/llm --skill dev.add-license

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.2 KB
---
name: dev.add-license
description: This skill should be used when the user wants to add a LICENSE file to their repository. Currently supports Apache License 2.0 with automatic copyright information detection from git configuration. Also updates package.json license field if the file exists.
---

# Add License

## Overview

Add an open source license file to a repository with automatically populated copyright information. Also updates the license field in package.json if present.

## Usage

When the user requests to add a license to their repository, follow this workflow:

### 1. Determine target location

Identify the project root directory. If the user is in a subdirectory of a git repository, check if they want the LICENSE file in the current directory or the repository root.

### 2. Extract copyright information

Extract copyright owner information from git configuration:

```bash
git config user.name
```

If git config is not available or the user prefers, ask for the copyright owner name explicitly.

For the copyright year, use the current year.

### 3. Create LICENSE file

Copy the Apache 2.0 license template from `assets/LICENSE-APACHE-2.0` to `LICENSE` in the target directory.

Then append the copyright notice to the end of the LICENSE file:

```
Copyright [YEAR] [COPYRIGHT OWNER NAME]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

Replace `[YEAR]` with the current year and `[COPYRIGHT OWNER NAME]` with the name extracted from git config.

### 4. Update package.json (if present)

Check if a `package.json` file exists in the target directory:

```bash
ls package.json
```

If `package.json` exists:
1. Read the package.json file
2. Update or add the `"license"` field to `"Apache-2.0"`
3. Write the updated package.json back to disk, preserving formatting

If the license field already exists, replace it. If it doesn't exist, add it to the JSON object.

### 5. Confirm completion

Inform the user that the LICENSE file has been created and confirm the copyright information used. If package.json was updated, mention that as well.

## Example Workflows

**User request:** "Add an Apache license to this project"

**Actions:**
1. Check current directory is a git repository
2. Run `git config user.name` to get copyright owner
3. Get current year
4. Read `assets/LICENSE-APACHE-2.0`
5. Write to `LICENSE` file with full license text
6. Append copyright notice with populated year and owner name
7. Check if `package.json` exists
8. If package.json exists, read it, update the `"license"` field to `"Apache-2.0"`, and write it back
9. Confirm: "Created LICENSE file with Apache 2.0 license. Copyright 2025 John Doe. Updated package.json with Apache-2.0 license."

## Resources

### assets/LICENSE-APACHE-2.0

Full text of the Apache License 2.0, used as the template for generating LICENSE files.

Overview

This skill adds an Apache License 2.0 file to a repository and automatically populates copyright information from git configuration. It can place the LICENSE in the chosen project directory and will update package.json's license field to "Apache-2.0" if present. It confirms the actions taken and the copyright details used.

How this skill works

The skill determines the target directory (current folder or repository root) and tries to read the local git user.name for the copyright owner. It copies a standard Apache 2.0 template into a LICENSE file, appends a populated copyright notice with the current year and owner, and checks for package.json. If package.json exists, it updates or inserts the "license" field to "Apache-2.0" and writes the file back while preserving formatting.

When to use it

  • You want to add an Apache 2.0 LICENSE file to a project quickly.
  • You want the copyright owner auto-filled from git configuration.
  • You need package.json updated to reflect the repository license.
  • You are in a subdirectory and want the LICENSE at repo root or current dir.
  • You prefer a standard, reproducible license addition workflow.

Best practices

  • Run the skill from the intended target directory or confirm whether to use repository root.
  • Ensure git user.name is set if you want automatic copyright detection.
  • Review the generated LICENSE file and appended copyright notice before committing.
  • Back up package.json or use version control so you can review the license field change.
  • If git config is not set or you prefer a different owner name, provide it explicitly when prompted.

Example use cases

  • A maintainer wants to add Apache 2.0 license to a new project and set package.json license correctly.
  • A contributor needs a properly formatted LICENSE at the repository root while working from a subfolder.
  • An automation step in a repository bootstrap that ensures a license file and package.json license are present.
  • A user without a configured git name provides the copyright owner interactively and gets a completed LICENSE file.

FAQ

What copyright name does the skill use?

It first attempts to read git config user.name. If that is unavailable or incorrect, you can provide the copyright owner name manually.

Will the skill overwrite an existing LICENSE or package.json?

The skill will create or overwrite LICENSE in the target directory and will update or replace the license field in package.json; review changes before committing.