# Create Library

> Use when working with a guide for creating new Scheme libraries (R7RS) in the project.

- Skill: `tomevault-io/create-library` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/create-library`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/create-library/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/create-library

---


# Create Library

This skill guides you through adding a new Scheme environment/library to the project. This is the standard way to organize Scheme code.

## Steps

### 1. Identify Location

*   **Core Libraries**: `src/core/scheme/` (for fundamental language features)
*   **Extra Libraries**: `src/extras/scheme/` (for extended functionality, interop, tools)

### 2. Create Library Definition (`.sld`)

Create a `.sld` file (e.g., `feature.sld`) in the appropriate directory.

```scheme
;; src/extras/scheme/feature.sld
(define-library (scheme-js feature)
  (export 
    my-procedure
    my-macro)
  (import (scheme base))
  
  ;; Option A: Include implementation file (Preferred for larger logic)
  (include "feature.scm")
  
  ;; Option B: Inline implementation (OK for very small libraries or simple re-exports)
  ;; (begin
  ;;   (define (my-procedure x) ...))
)
```

### 3. Create Implementation File (`.scm`)

If using `(include "feature.scm")`, create the corresponding `.scm` file in the same directory.

```scheme
;; src/extras/scheme/feature.scm

;; Note: No (library ...) wrapper here, this code is included directly into the library body.

(define (my-procedure x)
  (+ x 1))
  
(define-syntax my-macro
  ...)
```

### 4. Tests

*   **Create Test File**: Create a test file in `tests/` mirroring the source structure (e.g., `tests/extras/scheme/feature_tests.scm`).
*   **Format**:
    ```scheme
    (import (scheme base)
            (scheme-js feature) ;; Import your new library
            (scheme-js test))   ;; Import test framework

    (test-group "Feature Tests"
      (test "Description" expected-value expression)
      ;; ...
    )
    ```
*   **Register Test**: Add the test file to `tests/tests.js` (or `test_manifest.js` if applicable) so it runs with the suite.

### 5. Verification

*   Run `node run_tests_node.js`

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/mark-friedman) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

