Skip to main content

Syntax

Description

The import command reads JSONL (JSON Lines) files and loads them into the SQLite database. This is the inverse operation of export. Imported files:
  • specs.jsonl - Specifications
  • issues.jsonl - Issues
  • relationships.jsonl - Relationships (if present)
Use import to:
  • Restore from backups
  • Initialize new database from JSONL
  • Migrate data between systems
  • Recover from database corruption
  • Load shared project data
JSONL files are the source of truth in sudocode. Import rebuilds the database from these files, which is how sync works internally.

Arguments

string
required
Input directory containing JSONL filesExample: --input backups/2025-10-29Directory must contain specs.jsonl and/or issues.jsonl files.

Examples

Basic Import

Import from a directory:
This reads .sudocode/specs.jsonl and .sudocode/issues.jsonl and loads them into the database.

Restore from Backup

Restore database from backup:

Initialize New Database

Set up fresh database from JSONL:
1

Ensure clean state

2

Import from JSONL

3

Verify

Import Shared Data

Load data shared by team member:

JSON Output

Get machine-readable output:

How Import Works

Import processes JSONL files line by line:
1

Read JSONL files

Parse specs.jsonl and issues.jsonl from input directoryEach line is one JSON object representing an entity
2

Validate data

Check for required fields and valid structureSkip or error on invalid entries
3

Insert/update database

For each entity:
  • Check if ID exists in database
  • Insert if new, update if exists
  • Preserve UUIDs and timestamps
4

Import relationships

If relationships.jsonl exists, import relationship dataTags and other metadata embedded in entity records

Common Workflows

Disaster Recovery

Recover from database corruption:
1

Backup corrupted database

2

Import from JSONL (source of truth)

3

Sync to markdown

4

Verify

Migration from Old Version

Migrate data from older sudocode version:
1

Export from old version

In old project:
2

Copy JSONL files

3

Import in new version

In new project:
4

Verify migration

Compare counts with old project

Team Collaboration

Share and merge project data:
1

Team member A exports

2

Team member B receives and imports

3

Handle conflicts

Review imported changes and resolve any conflicts manually

Periodic Restore Test

Verify backups are valid:

Import Behavior

Conflict Resolution

When importing data that conflicts with existing database: Default behavior: Upsert (insert or update)
  • If entity ID exists: Update with imported data
  • If entity ID doesn’t exist: Insert new entity
  • Timestamps from JSONL are preserved
  • No manual conflict resolution
Import will overwrite existing data for matching IDs. Always backup before importing if you have unsaved local changes.

Data Preservation

What’s preserved during import:
  • Entity IDs (SPEC-001, ISSUE-001, etc.)
  • UUIDs
  • Timestamps (created_at, updated_at, closed_at)
  • All entity fields (title, content, priority, status, etc.)
  • Parent relationships
  • Tags
  • Archived status

Missing Files

If files are missing:
  • Only specs.jsonl → Imports specs only
  • Only issues.jsonl → Imports issues only
  • Both missing → Error (nothing to import)
  • Extra files → Ignored

Scripting Examples

Automated Backup Restore

Test backup integrity automatically:

Merge Multiple Exports

Combine data from multiple sources:

Selective Import

Import only specific entities:

Comparison with Sync and Export

import

JSONL → Database
  • One direction
  • Overwrites database
  • No markdown involved
  • Restoration/migration

export

Database → JSONL
  • One direction
  • Overwrites JSONL
  • No markdown involved
  • Backup/extraction

sync

Bidirectional full sync
  • Auto-detects direction
  • Handles all layers
  • Complete workflow
  • Normal operations
Typical workflow:
  1. Normal operations: Use sync
  2. Create backup: Use export
  3. Restore backup: Use import then sync --to-markdown

Common Questions

No, import is an upsert operation:
  • Matching IDs: Updated with imported data
  • New IDs: Inserted as new entities
  • Existing IDs not in import: Remain unchanged
To fully replace database, delete it first:
Import only updates the database. To update markdown:
Yes, but sequential imports will overwrite conflicts. For merging:
  1. Merge JSONL files manually using jq
  2. Import the merged result
Yes, if relationship data is embedded in entity records or if relationships.jsonl exists in the input directory.
Import will skip or error on invalid lines. Check logs for specific errors. Validate with:
Yes, import merges with existing data. Matching IDs are updated, new IDs are added. Always backup first:

Troubleshooting

Cause: Path is incorrect or directory not foundSolution: Verify path:
Use absolute path if needed:
Cause: Directory doesn’t contain specs.jsonl or issues.jsonlSolution: Check contents:
Ensure at least one JSONL file exists.
Cause: May have imported to wrong database or database not synced to markdownSolution:
  1. Check database:
  2. Sync to markdown:
Cause: Invalid JSON in JSONL fileSolution: Validate JSONL:
Fix or regenerate JSONL files from a clean source.
Cause: Another process is using the databaseSolution:
  1. Close other sudocode processes
  2. Wait and retry
  3. Check for zombie processes:

export

Export to JSONL

sync

Full bidirectional sync

status

Check import results

Next Steps

1

Backup current state

2

Import data

3

Sync to markdown

4

Verify import

5

Commit changes

Storage Model

Learn more about sudocode’s storage architecture and data flow