Syntax
Description
Theimport command reads JSONL (JSON Lines) files and loads them into the SQLite database. This is the inverse operation of export.
Imported files:
specs.jsonl- Specificationsissues.jsonl- Issuesrelationships.jsonl- Relationships (if present)
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
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:Expected output
Expected output
.sudocode/specs.jsonl and .sudocode/issues.jsonl and loads them into the database.
Restore from Backup
Restore database from backup:Expected output
Expected output
Initialize New Database
Set up fresh database from JSONL:Import Shared Data
Load data shared by team member:Expected output
Expected output
JSON Output
Get machine-readable output:JSON output
JSON output
How Import Works
Import processes JSONL files line by line:Read JSONL files
Parse
specs.jsonl and issues.jsonl from input directoryEach line is one JSON object representing an entityInsert/update database
For each entity:
- Check if ID exists in database
- Insert if new, update if exists
- Preserve UUIDs and timestamps
Common Workflows
Disaster Recovery
Recover from database corruption:Migration from Old Version
Migrate data from older sudocode version:Team Collaboration
Share and merge project data: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
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
- Normal operations: Use
sync - Create backup: Use
export - Restore backup: Use
importthensync --to-markdown
Common Questions
Does import delete existing data?
Does import delete existing data?
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
What happens to markdown files after import?
What happens to markdown files after import?
Import only updates the database. To update markdown:
Can I import from multiple sources?
Can I import from multiple sources?
Yes, but sequential imports will overwrite conflicts. For merging:
- Merge JSONL files manually using
jq - Import the merged result
Are relationships imported?
Are relationships imported?
Yes, if relationship data is embedded in entity records or if
relationships.jsonl exists in the input directory.What if JSONL format is invalid?
What if JSONL format is invalid?
Import will skip or error on invalid lines. Check logs for specific errors. Validate with:
Can I import into an existing project?
Can I import into an existing project?
Yes, import merges with existing data. Matching IDs are updated, new IDs are added. Always backup first:
Troubleshooting
Error: Input directory doesn't exist
Error: Input directory doesn't exist
Cause: Path is incorrect or directory not foundSolution:
Verify path:Use absolute path if needed:
Error: No JSONL files found
Error: No JSONL files found
Cause: Directory doesn’t contain Ensure at least one JSONL file exists.
specs.jsonl or issues.jsonlSolution:
Check contents:Import succeeds but data is missing
Import succeeds but data is missing
Cause: May have imported to wrong database or database not synced to markdownSolution:
- Check database:
- Sync to markdown:
Import fails with parse error
Import fails with parse error
Cause: Invalid JSON in JSONL fileSolution:
Validate JSONL:Fix or regenerate JSONL files from a clean source.
Database locked during import
Database locked during import
Cause: Another process is using the databaseSolution:
- Close other sudocode processes
- Wait and retry
- Check for zombie processes:
Related Commands
Next Steps
Storage Model
Learn more about sudocode’s storage architecture and data flow

